Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion threaded/_base_gthreadpooled.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
6 changes: 3 additions & 3 deletions threaded/_base_gthreadpooled.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
12 changes: 6 additions & 6 deletions threaded/_base_threaded.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand All @@ -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: ...
Expand All @@ -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
Expand All @@ -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: ...
Expand Down
5 changes: 3 additions & 2 deletions threaded/_class_decorator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ 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]: ...

@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: ...
2 changes: 1 addition & 1 deletion threaded/_gthreadpooled2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
2 changes: 1 addition & 1 deletion threaded/_gthreadpooled3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
5 changes: 4 additions & 1 deletion threaded/_py3_helpers.pyi
Original file line number Diff line number Diff line change
@@ -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]: ...
12 changes: 7 additions & 5 deletions threaded/_threaded2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
58 changes: 39 additions & 19 deletions threaded/_threaded3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,53 @@ 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]: ...

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: ...
Expand All @@ -48,7 +67,6 @@ def threadpooled(
*,
loop_getter: None = ...,
loop_getter_need_context: bool = ...

) -> typing.Callable[..., concurrent.futures.Future]: ...

@typing.overload
Expand All @@ -60,7 +78,6 @@ def threadpooled(
asyncio.AbstractEventLoop
],
loop_getter_need_context: bool = ...

) -> typing.Callable[..., asyncio.Task]: ...

@typing.overload
Expand All @@ -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: ...

Expand All @@ -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]: ...
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down