Skip to content

Commit

Permalink
Documentation build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ichorid committed Nov 24, 2021
1 parent 7a0e44d commit 9d22d48
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 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,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
10 changes: 5 additions & 5 deletions doc/extract_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -18,8 +18,8 @@ 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])
api_manager = RESTManager(config=config.api, root_endpoint=root_endpoint, state_dir=config.state_dir)
root_endpoint = RootEndpoint(middlewares=[ApiKeyMiddleware(config.api.key), error_middleware])
api_manager = RESTManager(config.api, root_endpoint, config.state_dir)
await api_manager.start()

fp = StringIO()
Expand Down
3 changes: 2 additions & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
sphinxcontrib.openapi
configobj
10 changes: 5 additions & 5 deletions src/tribler-common/tribler_common/patch_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"""
import builtins
from typing import List

import mock
from unittest.mock import Mock, patch

__all__ = ['patch_import']


_builtins_import = builtins.__import__


Expand Down Expand Up @@ -41,11 +41,11 @@ def try_import(module_name, *args, **kwargs):
raise ImportError

if strict:
return mock.MagicMock(**mock_kwargs)
return Mock(**mock_kwargs)

try:
return _builtins_import(module_name, *args, **kwargs)
except ImportError:
return mock.MagicMock(**mock_kwargs)
return Mock(**mock_kwargs)

return mock.patch('builtins.__import__', try_import)
return patch('builtins.__import__', try_import)
1 change: 0 additions & 1 deletion src/tribler-common/tribler_common/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
mock~=4.0.3
7 changes: 3 additions & 4 deletions src/tribler-common/tribler_common/tests/test_patch_import.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from mock.mock import MagicMock
from unittest.mock import Mock

import pytest

from tribler_common.patch_import import patch_import


pytestmark = pytest.mark.asyncio


Expand All @@ -26,13 +25,13 @@ async def test_mock_import_import_real_lib():
@patch_import(['time'])
async def test_mock_import_not_strict():
import time
assert not isinstance(time, MagicMock)
assert not isinstance(time, Mock)


@patch_import(['time'], strict=True)
async def test_mock_import_strict():
import time
assert isinstance(time, MagicMock)
assert isinstance(time, Mock)


@patch_import(['time'], always_raise_exception_on_import=True)
Expand Down

0 comments on commit 9d22d48

Please sign in to comment.