diff --git a/.isort.cfg b/.isort.cfg index 0f67f9d91ff..0b2a78b7a51 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -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,freezegun +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,yaml diff --git a/doc/extract_swagger.py b/doc/extract_swagger.py index 5a8450902ee..fa34375f465 100644 --- a/doc/extract_swagger.py +++ b/doc/extract_swagger.py @@ -5,11 +5,11 @@ import aiohttp +import yaml + from tribler_core.components.restapi.rest.rest_manager import ApiKeyMiddleware, RESTManager, error_middleware -from tribler_core.config.tribler_config import TriblerConfig from tribler_core.components.restapi.rest.root_endpoint import RootEndpoint - -import yaml +from tribler_core.config.tribler_config import TriblerConfig async def extract_swagger(destination_fn): @@ -18,7 +18,7 @@ async def extract_swagger(destination_fn): config.api.http_enabled = False config.api.https_enabled = False - root_endpoint = RootEndpoint(config, middlewares=[ApiKeyMiddleware(config.api.key), error_middleware]) + root_endpoint = RootEndpoint(middlewares=[ApiKeyMiddleware(config.api.key), error_middleware]) api_manager = RESTManager(config=config.api, root_endpoint=root_endpoint, state_dir=config.state_dir) await api_manager.start() diff --git a/doc/requirements.txt b/doc/requirements.txt index 1a84ca20b9e..1f7b6d9716e 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -6,4 +6,5 @@ sphinx>=3.0.4 # not directly required, pinned by Snyk to avoid a vulnerability sphinx_rtd_theme sphinxcontrib-httpdomain==1.5.0 sphinxcontrib-openapi -sphinxcontrib.openapi \ No newline at end of file +sphinxcontrib.openapi +configobj diff --git a/src/tribler-common/tribler_common/patch_import.py b/src/tribler-common/tribler_common/patch_import.py index 9888848609b..971609579f7 100644 --- a/src/tribler-common/tribler_common/patch_import.py +++ b/src/tribler-common/tribler_common/patch_import.py @@ -8,11 +8,11 @@ """ import builtins from typing import List - -import mock +from unittest.mock import MagicMock, patch __all__ = ['patch_import'] + _builtins_import = builtins.__import__ @@ -41,11 +41,11 @@ def try_import(module_name, *args, **kwargs): raise ImportError if strict: - return mock.MagicMock(**mock_kwargs) + return MagicMock(**mock_kwargs) try: return _builtins_import(module_name, *args, **kwargs) except ImportError: - return mock.MagicMock(**mock_kwargs) + return MagicMock(**mock_kwargs) - return mock.patch('builtins.__import__', try_import) + return patch('builtins.__import__', try_import) diff --git a/src/tribler-common/tribler_common/requirements.txt b/src/tribler-common/tribler_common/requirements.txt index 8280084634d..e69de29bb2d 100644 --- a/src/tribler-common/tribler_common/requirements.txt +++ b/src/tribler-common/tribler_common/requirements.txt @@ -1 +0,0 @@ -mock~=4.0.3 diff --git a/src/tribler-common/tribler_common/tests/test_dependencies.py b/src/tribler-common/tribler_common/tests/test_dependencies.py index 0e5e14d1596..7ad8a9212cd 100644 --- a/src/tribler-common/tribler_common/tests/test_dependencies.py +++ b/src/tribler-common/tribler_common/tests/test_dependencies.py @@ -37,7 +37,6 @@ async def test_get_dependencies(): # assert that in each scope dependencies are exist assert list(get_dependencies(Scope.gui)) assert list(get_dependencies(Scope.core)) - assert list(get_dependencies(Scope.common)) async def test_get_dependencies_wrong_scope(): diff --git a/src/tribler-common/tribler_common/tests/test_patch_import.py b/src/tribler-common/tribler_common/tests/test_patch_import.py index 5c6136392f4..aad9d16e0cd 100644 --- a/src/tribler-common/tribler_common/tests/test_patch_import.py +++ b/src/tribler-common/tribler_common/tests/test_patch_import.py @@ -1,10 +1,9 @@ -from mock.mock import MagicMock +from unittest.mock import MagicMock import pytest from tribler_common.patch_import import patch_import - pytestmark = pytest.mark.asyncio