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

@@ -3,6 +3,7 @@
from typing import Iterable, List, Optional, Type, Union
from types import ModuleType
from unittest.async_case import *
from unittest.case import *
from unittest.loader import *
from unittest.result import *

View File

@@ -0,0 +1,9 @@
import sys
from typing import Any, Awaitable, Callable
from .case import TestCase
if sys.version_info >= (3, 8):
class IsolatedAsyncioTestCase(TestCase):
async def asyncSetUp(self) -> None: ...
async def asyncTearDown(self) -> None: ...
def addAsyncCleanup(self, __func: Callable[..., Awaitable[Any]], *args: Any, **kwargs: Any) -> None: ...

View File

@@ -1,16 +1,19 @@
import logging
import sys
import unittest.result
from types import TracebackType
from typing import (
Any, AnyStr, Callable, Container, ContextManager, Dict, FrozenSet, Generic,
Iterable, List, NoReturn, Optional, overload, Pattern, Sequence, Set,
Tuple, Type, TypeVar, Union,
)
import logging
import unittest.result
from types import TracebackType
_E = TypeVar('_E', bound=BaseException)
_FT = TypeVar('_FT', bound=Callable[..., Any])
if sys.version_info >= (3, 8):
def addModuleCleanup(__function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
def doModuleCleanups() -> None: ...
def expectedFailure(func: _FT) -> _FT: ...
def skip(reason: str) -> Callable[[_FT], _FT]: ...
@@ -154,6 +157,11 @@ class TestCase:
def addCleanup(self, function: Callable[..., Any], *args: Any,
**kwargs: Any) -> None: ...
def doCleanups(self) -> None: ...
if sys.version_info >= (3, 8):
@classmethod
def addClassCleanup(cls, __function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
@classmethod
def doClassCleanups(cls) -> None: ...
def _formatMessage(self, msg: Optional[str], standardMsg: str) -> str: ... # undocumented
def _getAssertEqualityFunc(self, first: Any, second: Any) -> Callable[..., None]: ... # undocumented
# below is deprecated

View File

@@ -98,6 +98,8 @@ class MagicMixin:
NonCallableMagicMock = Any
MagicMock = Any
if sys.version_info >= (3, 8):
AsyncMock = Any
class MagicProxy:
name: Any