diff --git a/.travis.yml b/.travis.yml index 195ea96..8a92fed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,17 +22,17 @@ jobs: include: - stage: Static analisys python: 3.6 - services: skip + services: [] install: - *upgrade_python_toolset - pip install tox script: - - tox -e pylint,bandit + - tox -e pylint,bandit,mypy after_success: skip - stage: Code style check python: *mainstream_python - services: skip + services: [] install: - *upgrade_python_toolset - pip install tox diff --git a/threaded/_base_gthreadpooled.py b/threaded/_base_gthreadpooled.py index 52ad620..2fa8519 100644 --- a/threaded/_base_gthreadpooled.py +++ b/threaded/_base_gthreadpooled.py @@ -70,7 +70,7 @@ def configure( # pylint: enable=arguments-differ @classmethod - def shutdown(cls): # type: () -> None + def shutdown(cls): # type: (typing.Type[BaseGThreadPooled]) -> None """Shutdown executor. Due to not implemented method, set maxsize to 0 (do not accept new). diff --git a/threaded/_base_gthreadpooled.pyi b/threaded/_base_gthreadpooled.pyi index c648e0b..4292682 100644 --- a/threaded/_base_gthreadpooled.pyi +++ b/threaded/_base_gthreadpooled.pyi @@ -7,12 +7,12 @@ class BaseGThreadPooled(_base_threaded.APIPooled): @classmethod def configure( cls: typing.Type[BaseGThreadPooled], - max_workers: typing.Optional[int]=..., - hub: typing.Optional[gevent.hub.Hub]=... + max_workers: typing.Optional[int] = ..., + hub: typing.Optional[gevent.hub.Hub] = ..., ) -> None: ... @classmethod - def shutdown(cls) -> None: ... + def shutdown(cls: typing.Type[BaseGThreadPooled]) -> None: ... @property def executor(self) -> gevent.threadpool.ThreadPool: ... diff --git a/threaded/_base_threaded.pyi b/threaded/_base_threaded.pyi index f46c796..b25c468 100644 --- a/threaded/_base_threaded.pyi +++ b/threaded/_base_threaded.pyi @@ -8,7 +8,7 @@ def cpu_count() -> int: ... class APIPooled(_class_decorator.BaseDecorator, metaclass=abc.ABCMeta): @classmethod - def configure(cls: typing.Type[APIPooled], max_workers: typing.Optional[int]=...) -> None: ... + def configure(cls: typing.Type[APIPooled], max_workers: typing.Optional[int] = ...) -> None: ... @classmethod def shutdown(cls: typing.Type[APIPooled]) -> None: ... @@ -18,7 +18,7 @@ class APIPooled(_class_decorator.BaseDecorator, metaclass=abc.ABCMeta): class BasePooled(APIPooled): @classmethod - def configure(cls: typing.Type[BasePooled], max_workers: typing.Optional[int]=...) -> None: ... + def configure(cls: typing.Type[BasePooled], max_workers: typing.Optional[int] = ...) -> None: ... @classmethod def shutdown(cls: typing.Type[BasePooled]) -> None: ... @@ -31,9 +31,9 @@ class BasePooled(APIPooled): class BaseThreaded(_class_decorator.BaseDecorator): def __init__( self, - name: typing.Optional[typing.Union[str, typing.Callable]]=..., - daemon: bool=..., - started: bool=... + name: typing.Optional[typing.Union[str, typing.Callable]] = ..., + daemon: bool = ..., + started: bool = ..., ) -> None: ... @property @@ -48,7 +48,7 @@ class BaseThreaded(_class_decorator.BaseDecorator): def _get_function_wrapper(self, func: typing.Callable) -> typing.Callable[..., threading.Thread]: ... class ThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor): - def __init__(self, max_workers: typing.Optional[int]=...) -> None: ... + def __init__(self, max_workers: typing.Optional[int] = ...) -> None: ... @property def max_workers(self) -> int: ... diff --git a/threaded/_class_decorator.pyi b/threaded/_class_decorator.pyi index fe35d2f..436fab4 100644 --- a/threaded/_class_decorator.pyi +++ b/threaded/_class_decorator.pyi @@ -4,7 +4,8 @@ import typing class BaseDecorator(object, metaclass=abc.ABCMeta): __wrapped__: typing.Optional[typing.Callable] = ... - def __init__(self, func: typing.Optional[typing.Callable]=...) -> None: ... + + def __init__(self, func: typing.Optional[typing.Callable] = ...) -> None: ... @property def _func(self) -> typing.Optional[typing.Callable]: ... @@ -12,4 +13,4 @@ class BaseDecorator(object, metaclass=abc.ABCMeta): @abc.abstractmethod def _get_function_wrapper(self, func: typing.Callable) -> typing.Callable: ... - def __call__(self, *args: typing.Any, **kwargs: typing.Any) -> typing.Any: ... + def __call__(self, *args: typing.Tuple, **kwargs: typing.Dict) -> typing.Any: ... diff --git a/threaded/_gthreadpooled2.pyi b/threaded/_gthreadpooled2.pyi index 84d9427..47d7208 100644 --- a/threaded/_gthreadpooled2.pyi +++ b/threaded/_gthreadpooled2.pyi @@ -9,4 +9,4 @@ class GThreadPooled(_base_gthreadpooled.BaseGThreadPooled): ... def gthreadpooled(func: typing.Callable) -> typing.Callable[..., gevent.event.AsyncResult]: ... @typing.overload -def gthreadpooled(func: None=...) -> GThreadPooled: ... +def gthreadpooled(func: None = ...) -> GThreadPooled: ... diff --git a/threaded/_gthreadpooled3.pyi b/threaded/_gthreadpooled3.pyi index 84d9427..47d7208 100644 --- a/threaded/_gthreadpooled3.pyi +++ b/threaded/_gthreadpooled3.pyi @@ -9,4 +9,4 @@ class GThreadPooled(_base_gthreadpooled.BaseGThreadPooled): ... def gthreadpooled(func: typing.Callable) -> typing.Callable[..., gevent.event.AsyncResult]: ... @typing.overload -def gthreadpooled(func: None=...) -> GThreadPooled: ... +def gthreadpooled(func: None = ...) -> GThreadPooled: ... diff --git a/threaded/_py3_helpers.pyi b/threaded/_py3_helpers.pyi index 9262a45..3cb199f 100644 --- a/threaded/_py3_helpers.pyi +++ b/threaded/_py3_helpers.pyi @@ -1,5 +1,8 @@ import asyncio import typing -def get_loop(self: typing.Any, *args: typing.Tuple, **kwargs: typing.Dict) -> typing.Optional[asyncio.AbstractEventLoop]: ... +def get_loop( + self: typing.Any, *args: typing.Tuple, **kwargs: typing.Dict +) -> typing.Optional[asyncio.AbstractEventLoop]: ... + def await_if_required(target: typing.Callable) -> typing.Callable[..., typing.Any]: ... diff --git a/threaded/_threaded2.pyi b/threaded/_threaded2.pyi index cd52769..f220b16 100644 --- a/threaded/_threaded2.pyi +++ b/threaded/_threaded2.pyi @@ -7,17 +7,19 @@ class ThreadPooled(_base_threaded.BasePooled): ... class Threaded(_base_threaded.BaseThreaded): ... - - @typing.overload def threadpooled(func: typing.Callable) -> typing.Callable[..., concurrent.futures.Future]: ... @typing.overload -def threadpooled(func: None=...) -> ThreadPooled: ... +def threadpooled(func: None = ...) -> ThreadPooled: ... @typing.overload -def threaded(name: typing.Callable, daemon: bool=..., started: bool=...) -> typing.Callable[..., threading.Thread]: ... +def threaded( + name: typing.Callable, daemon: bool = ..., started: bool = ... +) -> typing.Callable[..., threading.Thread]: ... @typing.overload -def threaded(name: typing.Optional[str]=..., daemon: bool=..., started: bool=...) -> Threaded: ... +def threaded( + name: typing.Optional[str] = ..., daemon: bool = ..., started: bool = ... +) -> Threaded: ... diff --git a/threaded/_threaded3.pyi b/threaded/_threaded3.pyi index 12c7f6f..3c43a24 100644 --- a/threaded/_threaded3.pyi +++ b/threaded/_threaded3.pyi @@ -7,19 +7,32 @@ from . import _base_threaded, _class_decorator class ThreadPooled(_base_threaded.BasePooled): def __init__( self, - func: typing.Optional[typing.Callable]=..., + func: typing.Optional[typing.Callable] = ..., *, - loop_getter: typing.Optional[typing.Union[typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]]=..., - loop_getter_need_context: bool=... + loop_getter: typing.Optional[ + typing.Union[ + typing.Callable[..., asyncio.AbstractEventLoop], + asyncio.AbstractEventLoop, + ] + ] = ..., + loop_getter_need_context: bool = ... ) -> None: ... @property - def loop_getter(self) -> typing.Optional[typing.Union[typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]]: ... - + def loop_getter( + self + ) -> typing.Optional[ + typing.Union[ + typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop + ] + ]: ... @property + def loop_getter_need_context(self) -> bool: ... - def _get_function_wrapper(self, func: typing.Callable) -> typing.Callable[..., typing.Union[concurrent.futures.Future, asyncio.Task]]: ... # type: ignore + def _get_function_wrapper( # type: ignore + self, func: typing.Callable + ) -> typing.Callable[..., typing.Union[concurrent.futures.Future, asyncio.Task]]: ... class Threaded(_base_threaded.BaseThreaded): def _get_function_wrapper(self, func: typing.Callable) -> typing.Callable[..., threading.Thread]: ... @@ -27,14 +40,20 @@ class Threaded(_base_threaded.BaseThreaded): class AsyncIOTask(_class_decorator.BaseDecorator): def __init__( self, - func: typing.Optional[typing.Callable]=..., + func: typing.Optional[typing.Callable] = ..., *, - loop_getter: typing.Union[typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]=..., - loop_getter_need_context: bool=... + loop_getter: typing.Union[ + typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop + ] = ..., + loop_getter_need_context: bool = ... ) -> None: ... @property - def loop_getter(self) -> typing.Union[typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]: ... + def loop_getter( + self + ) -> typing.Union[ + typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop + ]: ... @property def loop_getter_need_context(self) -> bool: ... @@ -48,7 +67,6 @@ def threadpooled( *, loop_getter: None = ..., loop_getter_need_context: bool = ... - ) -> typing.Callable[..., concurrent.futures.Future]: ... @typing.overload @@ -60,7 +78,6 @@ def threadpooled( asyncio.AbstractEventLoop ], loop_getter_need_context: bool = ... - ) -> typing.Callable[..., asyncio.Task]: ... @typing.overload @@ -71,26 +88,29 @@ def threadpooled( None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop - ]=..., + ] = ..., loop_getter_need_context: bool = ... ) -> ThreadPooled: ... @typing.overload -def threaded(name: typing.Callable, daemon: bool = ..., started: bool = ...) -> typing.Callable[..., threading.Thread]: ... +def threaded( + name: typing.Callable, daemon: bool = ..., started: bool = ... +) -> typing.Callable[..., threading.Thread]: ... @typing.overload -def threaded(name: typing.Optional[str] = ..., daemon: bool = ..., started: bool = ...) -> Threaded: ... - +def threaded( + name: typing.Optional[str] = ..., daemon: bool = ..., started: bool = ... +) -> Threaded: ... @typing.overload def asynciotask( - func: None= ..., + func: None = ..., *, loop_getter: typing.Union[ typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop - ]=asyncio.get_event_loop, + ] = asyncio.get_event_loop, loop_getter_need_context: bool = ... ) -> AsyncIOTask: ... @@ -101,6 +121,6 @@ def asynciotask( loop_getter: typing.Union[ typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop - ]=asyncio.get_event_loop, + ] = asyncio.get_event_loop, loop_getter_need_context: bool = ... ) -> typing.Callable[..., asyncio.Task]: ... diff --git a/tox.ini b/tox.ini index 9ada10a..fe63f12 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ [tox] minversion = 2.0 -envlist = pep8, pep257, py{27,34,35,36,37,py,py3}, pylint, docs, bandit, py{34,35,36,37}-nocov, +envlist = pep8, pep257, py{27,34,35,36,37,py,py3}, pylint, docs, bandit, py{34,35,36,37}-nocov, mypy skipsdist = True skip_missing_interpreters = True