Annotations for remaining Python 3.8 additions (#3358)

* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock

Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.

* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
This commit is contained in:
Sebastian Rittau
2019-10-14 09:53:48 +02:00
committed by GitHub
parent 6507875f28
commit 0501e2b329
30 changed files with 419 additions and 102 deletions

View File

@@ -44,7 +44,12 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
# Future methods
def create_future(self) -> Future[Any]: ...
# Tasks methods
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
if sys.version_info >= (3, 8):
def create_task(
self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: Optional[str] = ...,
) -> Task[_T]: ...
else:
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ...
def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ...
# Methods for interacting with threads

View File

@@ -80,8 +80,14 @@ class AbstractEventLoop(metaclass=ABCMeta):
@abstractmethod
def create_future(self) -> Future[Any]: ...
# Tasks methods
@abstractmethod
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
if sys.version_info >= (3, 8):
@abstractmethod
def create_task(
self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: Optional[str] = ...,
) -> Task[_T]: ...
else:
@abstractmethod
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
@abstractmethod
def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ...
@abstractmethod

View File

@@ -98,6 +98,9 @@ class Task(Future[_T], Generic[_T]):
def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ...
def __repr__(self) -> str: ...
if sys.version_info >= (3, 8):
def get_name(self) -> str: ...
def set_name(self, value: object) -> None: ...
def get_stack(self, *, limit: int = ...) -> List[FrameType]: ...
def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ...
def cancel(self) -> bool: ...
@@ -106,5 +109,10 @@ class Task(Future[_T], Generic[_T]):
if sys.version_info >= (3, 7):
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task[Any]: ...
if sys.version_info >= (3, 8):
def create_task(
coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, name: Optional[str] = ...,
) -> Task[Any]: ...
else:
def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task[Any]: ...
def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ...