Skip to content

Commit

Permalink
Lints
Browse files Browse the repository at this point in the history
  • Loading branch information
ichorid committed Nov 23, 2021
1 parent a2032ce commit 91b9556
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ force_sort_within_sections=True
line_length=120
known_future_library=future
known_first_party=tribler_core,tribler_gui,tribler_common,run_tribler
known_third_party=pony,twisted,six,anydex,ipv8,libtorrent,lz4,PyQt5,zope,aiohttp,psutil,configobj,ipv8_service,asynctest,numpy,networkx,async_timeout,cherrypy,nose,validate,check_os,matplotlib,pyqtgraph,_socket,aiohttp_apispec,marshmallow,PIL,anyio
known_third_party=pony,twisted,six,anydex,ipv8,libtorrent,lz4,PyQt5,zope,aiohttp,psutil,configobj,ipv8_service,asynctest,numpy,networkx,async_timeout,cherrypy,nose,validate,check_os,matplotlib,pyqtgraph,_socket,aiohttp_apispec,marshmallow,PIL,anyio,freezegun
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

@pytest.fixture
def endpoint(mock_dlmgr, mock_lt_session):
endpoint = LibTorrentEndpoint(mock_dlmgr)

return endpoint
return LibTorrentEndpoint(mock_dlmgr)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

@pytest.fixture
def endpoint(mock_dlmgr):
endpoint = TorrentInfoEndpoint(mock_dlmgr)
return endpoint
return TorrentInfoEndpoint(mock_dlmgr)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ def return_exc(*args, **kwargs):
mock_dlmgr.metainfo_requests = {}

mock_gigachannel_community.remote_select_channel_contents = return_exc
collections_endpoint = ChannelsEndpoint(mock_dlmgr, mock_gigachannel_manager, mock_gigachannel_community, metadata_store, tags_db=tags_db)
channels_endpoint = ChannelsEndpoint(mock_dlmgr, mock_gigachannel_manager, mock_gigachannel_community ,metadata_store, tags_db=tags_db)
ep_args = [mock_dlmgr, mock_gigachannel_manager, mock_gigachannel_community, metadata_store]
ep_kwargs = {'tags_db': tags_db}
collections_endpoint = ChannelsEndpoint(*ep_args, **ep_kwargs)
channels_endpoint = ChannelsEndpoint(*ep_args, **ep_kwargs)

app = Application(middlewares=[error_middleware])
app.add_subapp('/channels', channels_endpoint.app)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ def mock_gigachannel_community():


@pytest.fixture
def endpoint(mock_gigachannel_community, metadata_store):
endpoint = RemoteQueryEndpoint(mock_gigachannel_community, metadata_store)
return endpoint
def endpoint(mock_gigachannel_community, metadata_store): # pylint: disable=W0621
return RemoteQueryEndpoint(mock_gigachannel_community, metadata_store)


@pytest.fixture
Expand All @@ -38,7 +37,7 @@ def rest_api(loop, aiohttp_client, endpoint): # pylint: disable=unused-argument
return loop.run_until_complete(aiohttp_client(app))


async def test_create_remote_search_request(rest_api, endpoint, mock_gigachannel_community):
async def test_create_remote_search_request(rest_api, endpoint, mock_gigachannel_community): # pylint: disable=W0621
"""
Test that remote search call is sent on a REST API search request
"""
Expand Down Expand Up @@ -71,7 +70,7 @@ def mock_send(**kwargs):
assert hexlify(sent['channel_pk']) == channel_pk


async def test_get_channels_peers(rest_api, endpoint, metadata_store, mock_gigachannel_community):
async def test_get_channels_peers(rest_api, endpoint, metadata_store, mock_gigachannel_community): # pylint: disable=W0621, C0321
"""
Test getting debug info about the state of channels to peers mapping
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

@pytest.fixture
def endpoint():
endpoint = CreateTorrentEndpoint(Mock())
return endpoint
return CreateTorrentEndpoint(Mock())


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

@pytest.fixture
def mock_tunnel_community():
mock_tunnel_community = Mock()
return mock_tunnel_community
return Mock()


@pytest.fixture
def endpoint(tmp_path, mock_tunnel_community, core_resource_monitor):
endpoint = DebugEndpoint(tmp_path, tmp_path / 'logs', tunnel_community=mock_tunnel_community, resource_monitor=core_resource_monitor)
return endpoint
def endpoint(tmp_path, mock_tunnel_community, core_resource_monitor): # pylint: disable=W0621
return DebugEndpoint(tmp_path, tmp_path / 'logs',
tunnel_community=mock_tunnel_community,
resource_monitor=core_resource_monitor)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def tribler_config(tmp_path):

@pytest.fixture
def endpoint(tribler_config):
endpoint = SettingsEndpoint(tribler_config)
return endpoint
return SettingsEndpoint(tribler_config)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

@pytest.fixture
def endpoint():
shutdown_callback = Mock()
endpoint = ShutdownEndpoint(shutdown_callback)
return endpoint
return ShutdownEndpoint(Mock())


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@


@pytest.fixture
def endpoint(bandwidth_db):
endpoint = TrustViewEndpoint(bandwidth_db)
return endpoint
def endpoint(bandwidth_db): # pylint: disable=W0621
return TrustViewEndpoint(bandwidth_db)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def maybe_add(self, path: str, endpoint_cls: Type[RESTEndpoint], *args, **kwargs
""" Add the corresponding endpoint to the path in case there are no `NoneComponent`
in *args or **kwargs
"""
if any(isinstance(arg, NoneComponent) for arg in (list(args) + list(kwargs.values()))):
if any(isinstance(arg, NoneComponent) for arg in list(args) + list(kwargs.values())):
self.logger.info("Endpoint %s can't load component, skipping init", path)
return

Expand All @@ -69,6 +69,7 @@ async def run(self):
metadata_store_component = await self.get_component(MetadataStoreComponent)

# fmt: off
# pylint: disable=C0301
key_component = await self.require_component(KeyComponent)
ipv8_component = await self.maybe_component(Ipv8Component)
libtorrent_component = await self.maybe_component(LibtorrentComponent)
Expand Down Expand Up @@ -106,10 +107,11 @@ async def run(self):
self.maybe_add('/remote_query', RemoteQueryEndpoint, gigachannel_component.community, metadata_store_component.mds)
self.maybe_add('/tags', TagsEndpoint, tag_component.tags_db, tag_component.community)

# pylint: enable=C0301
ipv8_root_endpoint = IPV8RootEndpoint()
for _, endpoint in ipv8_root_endpoint.endpoints.items():
endpoint.initialize(ipv8_component.ipv8)
self.root_endpoint.add_endpoint('/ipv8', ipv8_root_endpoint),
self.root_endpoint.add_endpoint('/ipv8', ipv8_root_endpoint)
# fmt: on

# ACHTUNG!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TagsEndpoint(RESTEndpoint):
"""

def __init__(self, db: TagDatabase, community: TagCommunity):
super(TagsEndpoint, self).__init__()
super().__init__()
self.db: TagDatabase = db
self.community: TagCommunity = community

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from aiohttp.web_app import Application

from freezegun import freeze_time

from ipv8.keyvault.crypto import default_eccrypto

from pony.orm import db_session

from freezegun import freeze_time

import pytest

from tribler_core.components.restapi.rest.base_api_test import do_request
Expand Down

0 comments on commit 91b9556

Please sign in to comment.