diff --git a/python/helpers/typeshed/README.md b/python/helpers/typeshed/README.md index 2cfb7c033a0e..9535cac066df 100644 --- a/python/helpers/typeshed/README.md +++ b/python/helpers/typeshed/README.md @@ -74,14 +74,6 @@ go into `third_party`. Since these modules can behave differently for different versions of Python, `third_party` has version subdirectories, just like `stdlib`. -NOTE: When you're contributing a new stub for a package that you did -not develop, please obtain consent of the package owner (this is -specified in [PEP -484](https://www.python.org/dev/peps/pep-0484/#the-typeshed-repo)). -The best way to obtain consent is to file an issue in the third-party -package's tracker and include the link to a positive response in your PR -for typeshed. - For more information on directory structure and stub versioning, see [the relevant section of CONTRIBUTING.md]( https://github.com/python/typeshed/blob/master/CONTRIBUTING.md#stub-versioning). diff --git a/python/helpers/typeshed/pyproject.toml b/python/helpers/typeshed/pyproject.toml new file mode 100644 index 000000000000..3ae4966f6f11 --- /dev/null +++ b/python/helpers/typeshed/pyproject.toml @@ -0,0 +1,11 @@ +[tool.black] +line_length = 130 +target_version = ["py37"] + +[tool.isort] +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +combine_as_imports = true +line_length = 130 diff --git a/python/helpers/typeshed/stdlib/2/__builtin__.pyi b/python/helpers/typeshed/stdlib/2/__builtin__.pyi index 37ef9566fd6d..7108eeb2abfb 100644 --- a/python/helpers/typeshed/stdlib/2/__builtin__.pyi +++ b/python/helpers/typeshed/stdlib/2/__builtin__.pyi @@ -348,7 +348,7 @@ class str(Sequence[str], _str_base): def __init__(self, o: object = ...) -> None: ... def capitalize(self) -> str: ... - def center(self, width: int, fillchar: str = ...) -> str: ... + def center(self, __width: int, __fillchar: str = ...) -> str: ... def count(self, x: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... @@ -364,37 +364,37 @@ class str(Sequence[str], _str_base): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[AnyStr]) -> AnyStr: ... - def ljust(self, width: int, fillchar: str = ...) -> str: ... + def join(self, __iterable: Iterable[AnyStr]) -> AnyStr: ... + def ljust(self, __width: int, __fillchar: str = ...) -> str: ... def lower(self) -> str: ... @overload - def lstrip(self, chars: str = ...) -> str: ... + def lstrip(self, __chars: str = ...) -> str: ... @overload - def lstrip(self, chars: unicode) -> unicode: ... + def lstrip(self, __chars: unicode) -> unicode: ... @overload - def partition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ... + def partition(self, __sep: bytearray) -> Tuple[str, bytearray, str]: ... @overload - def partition(self, sep: str) -> Tuple[str, str, str]: ... + def partition(self, __sep: str) -> Tuple[str, str, str]: ... @overload - def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def replace(self, old: AnyStr, new: AnyStr, count: int = ...) -> AnyStr: ... + def partition(self, __sep: unicode) -> Tuple[unicode, unicode, unicode]: ... + def replace(self, __old: AnyStr, __new: AnyStr, __count: int = ...) -> AnyStr: ... def rfind(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rindex(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... - def rjust(self, width: int, fillchar: str = ...) -> str: ... + def rjust(self, __width: int, __fillchar: str = ...) -> str: ... @overload - def rpartition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ... + def rpartition(self, __sep: bytearray) -> Tuple[str, bytearray, str]: ... @overload - def rpartition(self, sep: str) -> Tuple[str, str, str]: ... + def rpartition(self, __sep: str) -> Tuple[str, str, str]: ... @overload - def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... + def rpartition(self, __sep: unicode) -> Tuple[unicode, unicode, unicode]: ... @overload def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... @overload def rsplit(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... @overload - def rstrip(self, chars: str = ...) -> str: ... + def rstrip(self, __chars: str = ...) -> str: ... @overload - def rstrip(self, chars: unicode) -> unicode: ... + def rstrip(self, __chars: unicode) -> unicode: ... @overload def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... @overload @@ -402,14 +402,14 @@ class str(Sequence[str], _str_base): def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith(self, prefix: Union[Text, Tuple[Text, ...]]) -> bool: ... @overload - def strip(self, chars: str = ...) -> str: ... + def strip(self, __chars: str = ...) -> str: ... @overload def strip(self, chars: unicode) -> unicode: ... def swapcase(self) -> str: ... def title(self) -> str: ... - def translate(self, table: Optional[AnyStr], deletechars: AnyStr = ...) -> AnyStr: ... + def translate(self, __table: Optional[AnyStr], deletechars: AnyStr = ...) -> AnyStr: ... def upper(self) -> str: ... - def zfill(self, width: int) -> str: ... + def zfill(self, __width: int) -> str: ... def __add__(self, s: AnyStr) -> AnyStr: ... # Incompatible with Sequence.__contains__ @@ -450,15 +450,15 @@ class bytearray(MutableSequence[int], ByteString): @overload def __init__(self, length: int) -> None: ... def capitalize(self) -> bytearray: ... - def center(self, width: int, fillchar: bytes = ...) -> bytearray: ... - def count(self, x: str) -> int: ... + def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... + def count(self, __sub: str) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... - def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... + def endswith(self, __suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, iterable: Union[str, Iterable[int]]) -> None: ... - def find(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def index(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def insert(self, index: int, object: int) -> None: ... + def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... + def index(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... + def insert(self, __index: int, __item: int) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdigit(self) -> bool: ... @@ -466,34 +466,34 @@ class bytearray(MutableSequence[int], ByteString): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[str]) -> bytearray: ... - def ljust(self, width: int, fillchar: str = ...) -> bytearray: ... + def join(self, __iterable: Iterable[str]) -> bytearray: ... + def ljust(self, __width: int, __fillchar: str = ...) -> bytearray: ... def lower(self) -> bytearray: ... - def lstrip(self, chars: Optional[bytes] = ...) -> bytearray: ... - def partition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... - def replace(self, old: bytes, new: bytes, count: int = ...) -> bytearray: ... - def rfind(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... - def rjust(self, width: int, fillchar: bytes = ...) -> bytearray: ... - def rpartition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def lstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... + def partition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... + def rfind(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... + def rindex(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... + def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... + def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... - def rstrip(self, chars: Optional[bytes] = ...) -> bytearray: ... + def rstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( self, - prefix: Union[bytes, Tuple[bytes, ...]], - start: Optional[int] = ..., - end: Optional[int] = ..., + __prefix: Union[bytes, Tuple[bytes, ...]], + __start: Optional[int] = ..., + __end: Optional[int] = ..., ) -> bool: ... - def strip(self, chars: Optional[bytes] = ...) -> bytearray: ... + def strip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... def title(self) -> bytearray: ... - def translate(self, table: str) -> bytearray: ... + def translate(self, __table: str) -> bytearray: ... def upper(self) -> bytearray: ... - def zfill(self, width: int) -> bytearray: ... + def zfill(self, __width: int) -> bytearray: ... @staticmethod - def fromhex(s: str) -> bytearray: ... + def fromhex(__string: str) -> bytearray: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[int]: ... @@ -614,8 +614,8 @@ class tuple(Sequence[_T_co], Generic[_T_co]): def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... - def count(self, x: Any) -> int: ... - def index(self, x: Any) -> int: ... + def count(self, __value: Any) -> int: ... + def index(self, __value: Any) -> int: ... class function: # TODO not defined in builtins! @@ -628,13 +628,13 @@ class list(MutableSequence[_T], Generic[_T]): def __init__(self) -> None: ... @overload def __init__(self, iterable: Iterable[_T]) -> None: ... - def append(self, object: _T) -> None: ... - def extend(self, iterable: Iterable[_T]) -> None: ... - def pop(self, index: int = ...) -> _T: ... - def index(self, object: _T, start: int = ..., stop: int = ...) -> int: ... - def count(self, object: _T) -> int: ... - def insert(self, index: int, object: _T) -> None: ... - def remove(self, object: _T) -> None: ... + def append(self, __object: _T) -> None: ... + def extend(self, __iterable: Iterable[_T]) -> None: ... + def pop(self, __index: int = ...) -> _T: ... + def index(self, __value: _T, __start: int = ..., __stop: int = ...) -> int: ... + def count(self, __value: _T) -> int: ... + def insert(self, __index: int, __object: _T) -> None: ... + def remove(self, __value: _T) -> None: ... def reverse(self) -> None: ... def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ... @@ -681,7 +681,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def clear(self) -> None: ... def copy(self) -> Dict[_KT, _VT]: ... def popitem(self) -> Tuple[_KT, _VT]: ... - def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... + def setdefault(self, __key: _KT, __default: _VT = ...) -> _VT: ... @overload def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload @@ -696,10 +696,10 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def viewitems(self) -> ItemsView[_KT, _VT]: ... @staticmethod @overload - def fromkeys(seq: Iterable[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method (mypy/issues#328) + def fromkeys(__iterable: Iterable[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method (mypy/issues#328) @staticmethod @overload - def fromkeys(seq: Iterable[_T], value: _S) -> Dict[_T, _S]: ... + def fromkeys(__iterable: Iterable[_T], __value: _S) -> Dict[_T, _S]: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... @@ -802,23 +802,23 @@ long = int NotImplemented: Any -def abs(__n: SupportsAbs[_T]) -> _T: ... -def all(__i: Iterable[object]) -> bool: ... -def any(__i: Iterable[object]) -> bool: ... +def abs(__x: SupportsAbs[_T]) -> _T: ... +def all(__iterable: Iterable[object]) -> bool: ... +def any(__iterable: Iterable[object]) -> bool: ... def apply(__func: Callable[..., _T], __args: Optional[Sequence[Any]] = ..., __kwds: Optional[Mapping[str, Any]] = ...) -> _T: ... def bin(__number: Union[int, _SupportsIndex]) -> str: ... -def callable(__o: object) -> bool: ... -def chr(__code: int) -> str: ... +def callable(__obj: object) -> bool: ... +def chr(__i: int) -> str: ... def cmp(__x: Any, __y: Any) -> int: ... _N1 = TypeVar('_N1', bool, int, float, complex) def coerce(__x: _N1, __y: _N1) -> Tuple[_N1, _N1]: ... def compile(source: Union[Text, mod], filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... -def delattr(__o: Any, __name: Text) -> None: ... +def delattr(__obj: Any, __name: Text) -> None: ... def dir(__o: object = ...) -> List[str]: ... _N2 = TypeVar('_N2', int, float) -def divmod(__a: _N2, __b: _N2) -> Tuple[_N2, _N2]: ... +def divmod(__x: _N2, __y: _N2) -> Tuple[_N2, _N2]: ... def eval(__source: Union[Text, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ...) -> Any: ... def execfile(__filename: str, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Dict[str, Any]] = ...) -> None: ... def exit(code: object = ...) -> NoReturn: ... @@ -832,13 +832,13 @@ def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ... @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... -def format(__o: object, __format_spec: str = ...) -> str: ... # TODO unicode +def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ... def globals() -> Dict[str, Any]: ... -def hasattr(__o: Any, __name: Text) -> bool: ... -def hash(__o: object) -> int: ... -def hex(__i: Union[int, _SupportsIndex]) -> str: ... -def id(__o: object) -> int: ... +def hasattr(__obj: Any, __name: Text) -> bool: ... +def hash(__obj: object) -> int: ... +def hex(__number: Union[int, _SupportsIndex]) -> str: ... +def id(__obj: object) -> int: ... def input(__prompt: Any = ...) -> Any: ... def intern(__string: str) -> str: ... @overload @@ -847,9 +847,9 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... -def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... -def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... -def len(__o: Sized) -> int: ... +def isinstance(__obj: object, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def len(__obj: Sized) -> int: ... def locals() -> Dict[str, Any]: ... @overload def map(__func: None, __iter1: Iterable[_T1]) -> List[_T1]: ... @@ -929,7 +929,7 @@ def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... def next(__i: Iterator[_T]) -> _T: ... @overload def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... -def oct(__i: Union[int, _SupportsIndex]) -> str: ... +def oct(__number: Union[int, _SupportsIndex]) -> str: ... def open(name: Union[unicode, int], mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... @@ -941,13 +941,11 @@ class _Writer(Protocol): def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ... @overload -def pow(__x: int, __y: int) -> Any: ... # The return type can be int or float, depending on y +def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative @overload -def pow(__x: int, __y: int, __z: int) -> Any: ... +def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload -def pow(__x: float, __y: float) -> float: ... -@overload -def pow(__x: float, __y: float, __z: float) -> float: ... +def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... def quit(code: object = ...) -> NoReturn: ... def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ... def raw_input(__prompt: Any = ...) -> str: ... @@ -960,7 +958,7 @@ def reload(__module: Any) -> Any: ... def reversed(__object: Sequence[_T]) -> Iterator[_T]: ... @overload def reversed(__object: Reversible[_T]) -> Iterator[_T]: ... -def repr(__o: object) -> str: ... +def repr(__obj: object) -> str: ... @overload def round(number: float) -> float: ... @overload @@ -969,7 +967,7 @@ def round(number: float, ndigits: int) -> float: ... def round(number: SupportsFloat) -> float: ... @overload def round(number: SupportsFloat, ndigits: int) -> float: ... -def setattr(__object: Any, __name: Text, __value: Any) -> None: ... +def setattr(__obj: Any, __name: Text, __value: Any) -> None: ... def sorted(__iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., diff --git a/python/helpers/typeshed/stdlib/2/builtins.pyi b/python/helpers/typeshed/stdlib/2/builtins.pyi index 37ef9566fd6d..7108eeb2abfb 100644 --- a/python/helpers/typeshed/stdlib/2/builtins.pyi +++ b/python/helpers/typeshed/stdlib/2/builtins.pyi @@ -348,7 +348,7 @@ class str(Sequence[str], _str_base): def __init__(self, o: object = ...) -> None: ... def capitalize(self) -> str: ... - def center(self, width: int, fillchar: str = ...) -> str: ... + def center(self, __width: int, __fillchar: str = ...) -> str: ... def count(self, x: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... @@ -364,37 +364,37 @@ class str(Sequence[str], _str_base): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[AnyStr]) -> AnyStr: ... - def ljust(self, width: int, fillchar: str = ...) -> str: ... + def join(self, __iterable: Iterable[AnyStr]) -> AnyStr: ... + def ljust(self, __width: int, __fillchar: str = ...) -> str: ... def lower(self) -> str: ... @overload - def lstrip(self, chars: str = ...) -> str: ... + def lstrip(self, __chars: str = ...) -> str: ... @overload - def lstrip(self, chars: unicode) -> unicode: ... + def lstrip(self, __chars: unicode) -> unicode: ... @overload - def partition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ... + def partition(self, __sep: bytearray) -> Tuple[str, bytearray, str]: ... @overload - def partition(self, sep: str) -> Tuple[str, str, str]: ... + def partition(self, __sep: str) -> Tuple[str, str, str]: ... @overload - def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def replace(self, old: AnyStr, new: AnyStr, count: int = ...) -> AnyStr: ... + def partition(self, __sep: unicode) -> Tuple[unicode, unicode, unicode]: ... + def replace(self, __old: AnyStr, __new: AnyStr, __count: int = ...) -> AnyStr: ... def rfind(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rindex(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... - def rjust(self, width: int, fillchar: str = ...) -> str: ... + def rjust(self, __width: int, __fillchar: str = ...) -> str: ... @overload - def rpartition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ... + def rpartition(self, __sep: bytearray) -> Tuple[str, bytearray, str]: ... @overload - def rpartition(self, sep: str) -> Tuple[str, str, str]: ... + def rpartition(self, __sep: str) -> Tuple[str, str, str]: ... @overload - def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... + def rpartition(self, __sep: unicode) -> Tuple[unicode, unicode, unicode]: ... @overload def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... @overload def rsplit(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... @overload - def rstrip(self, chars: str = ...) -> str: ... + def rstrip(self, __chars: str = ...) -> str: ... @overload - def rstrip(self, chars: unicode) -> unicode: ... + def rstrip(self, __chars: unicode) -> unicode: ... @overload def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... @overload @@ -402,14 +402,14 @@ class str(Sequence[str], _str_base): def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith(self, prefix: Union[Text, Tuple[Text, ...]]) -> bool: ... @overload - def strip(self, chars: str = ...) -> str: ... + def strip(self, __chars: str = ...) -> str: ... @overload def strip(self, chars: unicode) -> unicode: ... def swapcase(self) -> str: ... def title(self) -> str: ... - def translate(self, table: Optional[AnyStr], deletechars: AnyStr = ...) -> AnyStr: ... + def translate(self, __table: Optional[AnyStr], deletechars: AnyStr = ...) -> AnyStr: ... def upper(self) -> str: ... - def zfill(self, width: int) -> str: ... + def zfill(self, __width: int) -> str: ... def __add__(self, s: AnyStr) -> AnyStr: ... # Incompatible with Sequence.__contains__ @@ -450,15 +450,15 @@ class bytearray(MutableSequence[int], ByteString): @overload def __init__(self, length: int) -> None: ... def capitalize(self) -> bytearray: ... - def center(self, width: int, fillchar: bytes = ...) -> bytearray: ... - def count(self, x: str) -> int: ... + def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... + def count(self, __sub: str) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... - def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... + def endswith(self, __suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, iterable: Union[str, Iterable[int]]) -> None: ... - def find(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def index(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def insert(self, index: int, object: int) -> None: ... + def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... + def index(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... + def insert(self, __index: int, __item: int) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdigit(self) -> bool: ... @@ -466,34 +466,34 @@ class bytearray(MutableSequence[int], ByteString): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[str]) -> bytearray: ... - def ljust(self, width: int, fillchar: str = ...) -> bytearray: ... + def join(self, __iterable: Iterable[str]) -> bytearray: ... + def ljust(self, __width: int, __fillchar: str = ...) -> bytearray: ... def lower(self) -> bytearray: ... - def lstrip(self, chars: Optional[bytes] = ...) -> bytearray: ... - def partition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... - def replace(self, old: bytes, new: bytes, count: int = ...) -> bytearray: ... - def rfind(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... - def rjust(self, width: int, fillchar: bytes = ...) -> bytearray: ... - def rpartition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def lstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... + def partition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... + def rfind(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... + def rindex(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... + def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... + def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... - def rstrip(self, chars: Optional[bytes] = ...) -> bytearray: ... + def rstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( self, - prefix: Union[bytes, Tuple[bytes, ...]], - start: Optional[int] = ..., - end: Optional[int] = ..., + __prefix: Union[bytes, Tuple[bytes, ...]], + __start: Optional[int] = ..., + __end: Optional[int] = ..., ) -> bool: ... - def strip(self, chars: Optional[bytes] = ...) -> bytearray: ... + def strip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... def title(self) -> bytearray: ... - def translate(self, table: str) -> bytearray: ... + def translate(self, __table: str) -> bytearray: ... def upper(self) -> bytearray: ... - def zfill(self, width: int) -> bytearray: ... + def zfill(self, __width: int) -> bytearray: ... @staticmethod - def fromhex(s: str) -> bytearray: ... + def fromhex(__string: str) -> bytearray: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[int]: ... @@ -614,8 +614,8 @@ class tuple(Sequence[_T_co], Generic[_T_co]): def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... - def count(self, x: Any) -> int: ... - def index(self, x: Any) -> int: ... + def count(self, __value: Any) -> int: ... + def index(self, __value: Any) -> int: ... class function: # TODO not defined in builtins! @@ -628,13 +628,13 @@ class list(MutableSequence[_T], Generic[_T]): def __init__(self) -> None: ... @overload def __init__(self, iterable: Iterable[_T]) -> None: ... - def append(self, object: _T) -> None: ... - def extend(self, iterable: Iterable[_T]) -> None: ... - def pop(self, index: int = ...) -> _T: ... - def index(self, object: _T, start: int = ..., stop: int = ...) -> int: ... - def count(self, object: _T) -> int: ... - def insert(self, index: int, object: _T) -> None: ... - def remove(self, object: _T) -> None: ... + def append(self, __object: _T) -> None: ... + def extend(self, __iterable: Iterable[_T]) -> None: ... + def pop(self, __index: int = ...) -> _T: ... + def index(self, __value: _T, __start: int = ..., __stop: int = ...) -> int: ... + def count(self, __value: _T) -> int: ... + def insert(self, __index: int, __object: _T) -> None: ... + def remove(self, __value: _T) -> None: ... def reverse(self) -> None: ... def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ... @@ -681,7 +681,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def clear(self) -> None: ... def copy(self) -> Dict[_KT, _VT]: ... def popitem(self) -> Tuple[_KT, _VT]: ... - def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... + def setdefault(self, __key: _KT, __default: _VT = ...) -> _VT: ... @overload def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload @@ -696,10 +696,10 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def viewitems(self) -> ItemsView[_KT, _VT]: ... @staticmethod @overload - def fromkeys(seq: Iterable[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method (mypy/issues#328) + def fromkeys(__iterable: Iterable[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method (mypy/issues#328) @staticmethod @overload - def fromkeys(seq: Iterable[_T], value: _S) -> Dict[_T, _S]: ... + def fromkeys(__iterable: Iterable[_T], __value: _S) -> Dict[_T, _S]: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... @@ -802,23 +802,23 @@ long = int NotImplemented: Any -def abs(__n: SupportsAbs[_T]) -> _T: ... -def all(__i: Iterable[object]) -> bool: ... -def any(__i: Iterable[object]) -> bool: ... +def abs(__x: SupportsAbs[_T]) -> _T: ... +def all(__iterable: Iterable[object]) -> bool: ... +def any(__iterable: Iterable[object]) -> bool: ... def apply(__func: Callable[..., _T], __args: Optional[Sequence[Any]] = ..., __kwds: Optional[Mapping[str, Any]] = ...) -> _T: ... def bin(__number: Union[int, _SupportsIndex]) -> str: ... -def callable(__o: object) -> bool: ... -def chr(__code: int) -> str: ... +def callable(__obj: object) -> bool: ... +def chr(__i: int) -> str: ... def cmp(__x: Any, __y: Any) -> int: ... _N1 = TypeVar('_N1', bool, int, float, complex) def coerce(__x: _N1, __y: _N1) -> Tuple[_N1, _N1]: ... def compile(source: Union[Text, mod], filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... -def delattr(__o: Any, __name: Text) -> None: ... +def delattr(__obj: Any, __name: Text) -> None: ... def dir(__o: object = ...) -> List[str]: ... _N2 = TypeVar('_N2', int, float) -def divmod(__a: _N2, __b: _N2) -> Tuple[_N2, _N2]: ... +def divmod(__x: _N2, __y: _N2) -> Tuple[_N2, _N2]: ... def eval(__source: Union[Text, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ...) -> Any: ... def execfile(__filename: str, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Dict[str, Any]] = ...) -> None: ... def exit(code: object = ...) -> NoReturn: ... @@ -832,13 +832,13 @@ def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ... @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... -def format(__o: object, __format_spec: str = ...) -> str: ... # TODO unicode +def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ... def globals() -> Dict[str, Any]: ... -def hasattr(__o: Any, __name: Text) -> bool: ... -def hash(__o: object) -> int: ... -def hex(__i: Union[int, _SupportsIndex]) -> str: ... -def id(__o: object) -> int: ... +def hasattr(__obj: Any, __name: Text) -> bool: ... +def hash(__obj: object) -> int: ... +def hex(__number: Union[int, _SupportsIndex]) -> str: ... +def id(__obj: object) -> int: ... def input(__prompt: Any = ...) -> Any: ... def intern(__string: str) -> str: ... @overload @@ -847,9 +847,9 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... -def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... -def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... -def len(__o: Sized) -> int: ... +def isinstance(__obj: object, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def len(__obj: Sized) -> int: ... def locals() -> Dict[str, Any]: ... @overload def map(__func: None, __iter1: Iterable[_T1]) -> List[_T1]: ... @@ -929,7 +929,7 @@ def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... def next(__i: Iterator[_T]) -> _T: ... @overload def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... -def oct(__i: Union[int, _SupportsIndex]) -> str: ... +def oct(__number: Union[int, _SupportsIndex]) -> str: ... def open(name: Union[unicode, int], mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... @@ -941,13 +941,11 @@ class _Writer(Protocol): def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ... @overload -def pow(__x: int, __y: int) -> Any: ... # The return type can be int or float, depending on y +def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative @overload -def pow(__x: int, __y: int, __z: int) -> Any: ... +def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload -def pow(__x: float, __y: float) -> float: ... -@overload -def pow(__x: float, __y: float, __z: float) -> float: ... +def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... def quit(code: object = ...) -> NoReturn: ... def range(__x: int, __y: int = ..., __step: int = ...) -> List[int]: ... def raw_input(__prompt: Any = ...) -> str: ... @@ -960,7 +958,7 @@ def reload(__module: Any) -> Any: ... def reversed(__object: Sequence[_T]) -> Iterator[_T]: ... @overload def reversed(__object: Reversible[_T]) -> Iterator[_T]: ... -def repr(__o: object) -> str: ... +def repr(__obj: object) -> str: ... @overload def round(number: float) -> float: ... @overload @@ -969,7 +967,7 @@ def round(number: float, ndigits: int) -> float: ... def round(number: SupportsFloat) -> float: ... @overload def round(number: SupportsFloat, ndigits: int) -> float: ... -def setattr(__object: Any, __name: Text, __value: Any) -> None: ... +def setattr(__obj: Any, __name: Text, __value: Any) -> None: ... def sorted(__iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., diff --git a/python/helpers/typeshed/stdlib/2/posix.pyi b/python/helpers/typeshed/stdlib/2/posix.pyi index 6cfd8520a15f..e85a2a55f4c9 100644 --- a/python/helpers/typeshed/stdlib/2/posix.pyi +++ b/python/helpers/typeshed/stdlib/2/posix.pyi @@ -1,4 +1,4 @@ -from typing import AnyStr, Dict, List, Mapping, Tuple, Union, Sequence, IO, Optional, TypeVar +from typing import AnyStr, Dict, IO, List, Mapping, NamedTuple, Optional, Sequence, Tuple, TypeVar, Union error = OSError @@ -78,10 +78,7 @@ class stat_result(object): st_mtime: int st_ctime: int -class statvfs_result(object): - n_fields: int - n_sequence_fields: int - n_unnamed_fields: int +class statvfs_result(NamedTuple): f_bsize: int f_frsize: int f_blocks: int diff --git a/python/helpers/typeshed/stdlib/2/sys.pyi b/python/helpers/typeshed/stdlib/2/sys.pyi index be688f5b4f26..f8651abdb506 100644 --- a/python/helpers/typeshed/stdlib/2/sys.pyi +++ b/python/helpers/typeshed/stdlib/2/sys.pyi @@ -89,8 +89,8 @@ last_traceback: TracebackType meta_path: List[Any] path_hooks: List[Any] path_importer_cache: Dict[str, Any] -displayhook: Optional[Callable[[int], None]] -excepthook: Optional[Callable[[type, BaseException, TracebackType], None]] +displayhook: Callable[[object], Any] +excepthook: Callable[[Type[BaseException], BaseException, TracebackType], Any] exc_type: Optional[type] exc_value: Union[BaseException, ClassType] exc_traceback: TracebackType @@ -112,7 +112,7 @@ def _clear_type_cache() -> None: ... def _current_frames() -> Dict[int, FrameType]: ... def _getframe(depth: int = ...) -> FrameType: ... def call_tracing(fn: Any, args: Any) -> Any: ... -def __displayhook__(value: int) -> None: ... +def __displayhook__(value: object) -> None: ... def __excepthook__(type_: type, value: BaseException, traceback: TracebackType) -> None: ... def exc_clear() -> None: ... def exc_info() -> _OptExcInfo: ... diff --git a/python/helpers/typeshed/stdlib/2/unittest.pyi b/python/helpers/typeshed/stdlib/2/unittest.pyi index 4eb84617dc79..b138216feaf1 100644 --- a/python/helpers/typeshed/stdlib/2/unittest.pyi +++ b/python/helpers/typeshed/stdlib/2/unittest.pyi @@ -207,12 +207,11 @@ class TestCase(Testable): def _formatMessage(self, msg: Optional[Text], standardMsg: Text) -> str: ... # undocumented def _getAssertEqualityFunc(self, first: Any, second: Any) -> Callable[..., None]: ... # undocumented -class FunctionTestCase(Testable): +class FunctionTestCase(TestCase): def __init__(self, testFunc: Callable[[], None], setUp: Optional[Callable[[], None]] = ..., tearDown: Optional[Callable[[], None]] = ..., description: Optional[str] = ...) -> None: ... - def run(self, result: TestResult) -> None: ... def debug(self) -> None: ... def countTestCases(self) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/argparse.pyi b/python/helpers/typeshed/stdlib/2and3/argparse.pyi index 2c33cac7122d..333992a2749d 100644 --- a/python/helpers/typeshed/stdlib/2and3/argparse.pyi +++ b/python/helpers/typeshed/stdlib/2and3/argparse.pyi @@ -135,7 +135,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def parse_args(self, *, namespace: _N) -> _N: ... if sys.version_info >= (3, 7): - def add_subparsers(self, title: str = ..., + def add_subparsers(self, *, title: str = ..., description: Optional[str] = ..., prog: str = ..., parser_class: Type[ArgumentParser] = ..., @@ -146,7 +146,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): help: Optional[str] = ..., metavar: Optional[str] = ...) -> _SubParsersAction: ... else: - def add_subparsers(self, title: Text = ..., + def add_subparsers(self, *, title: Text = ..., description: Optional[Text] = ..., prog: Text = ..., parser_class: Type[ArgumentParser] = ..., @@ -379,14 +379,23 @@ class _SubParsersAction(Action): _name_parser_map: Dict[_Text, ArgumentParser] choices: Dict[_Text, ArgumentParser] _choices_actions: List[Action] - def __init__(self, - option_strings: Sequence[Text], - prog: Text, - parser_class: Type[ArgumentParser], - dest: Text = ..., - required: bool = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...) -> None: ... + if sys.version_info >= (3, 7): + def __init__(self, + option_strings: Sequence[Text], + prog: Text, + parser_class: Type[ArgumentParser], + dest: Text = ..., + required: bool = ..., + help: Optional[Text] = ..., + metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...) -> None: ... + else: + def __init__(self, + option_strings: Sequence[Text], + prog: Text, + parser_class: Type[ArgumentParser], + dest: Text = ..., + help: Optional[Text] = ..., + metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ... def _get_subactions(self) -> List[Action]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi index 13117947161e..e37e6da80921 100644 --- a/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi @@ -57,7 +57,32 @@ class Logger(Filterer): def isEnabledFor(self, level: int) -> bool: ... def getEffectiveLevel(self) -> int: ... def getChild(self, suffix: str) -> Logger: ... - if sys.version_info >= (3,): + if sys.version_info >= (3, 8): + def debug(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def info(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def warning(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def warn(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def error(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def exception(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def critical(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def log(self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + elif sys.version_info >= (3,): def debug(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... @@ -112,7 +137,9 @@ class Logger(Filterer): def filter(self, record: LogRecord) -> bool: ... def addHandler(self, hdlr: Handler) -> None: ... def removeHandler(self, hdlr: Handler) -> None: ... - if sys.version_info >= (3,): + if sys.version_info >= (3, 8): + def findCaller(self, stack_info: bool = ..., stacklevel: int = ...) -> Tuple[str, int, str, Optional[str]]: ... + elif sys.version_info >= (3,): def findCaller(self, stack_info: bool = ...) -> Tuple[str, int, str, Optional[str]]: ... else: def findCaller(self) -> Tuple[str, int, str]: ... @@ -176,7 +203,11 @@ class Formatter: default_time_format: str default_msec_format: str - if sys.version_info >= (3,): + if sys.version_info >= (3, 8): + def __init__(self, fmt: Optional[str] = ..., + datefmt: Optional[str] = ..., + style: str = ..., validate: bool = ...) -> None: ... + elif sys.version_info >= (3,): def __init__(self, fmt: Optional[str] = ..., datefmt: Optional[str] = ..., style: str = ...) -> None: ... @@ -242,7 +273,32 @@ class LoggerAdapter: extra: Mapping[str, Any] def __init__(self, logger: Logger, extra: Mapping[str, Any]) -> None: ... def process(self, msg: Any, kwargs: MutableMapping[str, Any]) -> Tuple[Any, MutableMapping[str, Any]]: ... - if sys.version_info >= (3,): + if sys.version_info >= (3, 8): + def debug(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def info(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def warning(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def warn(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def error(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def exception(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def critical(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def log(self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + elif sys.version_info >= (3,): def debug(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... @@ -307,7 +363,32 @@ def getLoggerClass() -> type: ... if sys.version_info >= (3,): def getLogRecordFactory() -> Callable[..., LogRecord]: ... -if sys.version_info >= (3,): +if sys.version_info >= (3, 8): + def debug(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def info(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def warning(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def warn(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def error(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def critical(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def exception(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... + def log(level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., + stack_info: bool = ..., stacklevel: int = ..., extra: Optional[Dict[str, Any]] = ..., + **kwargs: Any) -> None: ... +elif sys.version_info >= (3,): def debug(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... @@ -356,7 +437,12 @@ def getLevelName(lvl: Union[int, str]) -> Any: ... def makeLogRecord(attrdict: Mapping[str, Any]) -> LogRecord: ... -if sys.version_info >= (3,): +if sys.version_info >= (3, 8): + def basicConfig(*, filename: Optional[_Path] = ..., filemode: str = ..., + format: str = ..., datefmt: Optional[str] = ..., style: str = ..., + level: Optional[_Level] = ..., stream: Optional[IO[str]] = ..., + handlers: Optional[Iterable[Handler]] = ..., force: bool = ...) -> None: ... +elif sys.version_info >= (3,): def basicConfig(*, filename: Optional[_Path] = ..., filemode: str = ..., format: str = ..., datefmt: Optional[str] = ..., style: str = ..., level: Optional[_Level] = ..., stream: Optional[IO[str]] = ..., @@ -398,6 +484,7 @@ class FileHandler(StreamHandler): delay: bool # undocumented def __init__(self, filename: _Path, mode: str = ..., encoding: Optional[str] = ..., delay: bool = ...) -> None: ... + def _open(self) -> IO[Any]: ... class NullHandler(Handler): ... diff --git a/python/helpers/typeshed/stdlib/2and3/logging/handlers.pyi b/python/helpers/typeshed/stdlib/2and3/logging/handlers.pyi index 161eb6098c9e..0bc578aaf080 100644 --- a/python/helpers/typeshed/stdlib/2and3/logging/handlers.pyi +++ b/python/helpers/typeshed/stdlib/2and3/logging/handlers.pyi @@ -29,8 +29,11 @@ SYSLOG_UDP_PORT: int SYSLOG_TCP_PORT: int class WatchedFileHandler(FileHandler): + dev: int + ino: int def __init__(self, filename: _Path, mode: str = ..., encoding: Optional[str] = ..., delay: bool = ...) -> None: ... + def _statstream(self) -> None: ... if sys.version_info >= (3,): diff --git a/python/helpers/typeshed/stdlib/2and3/math.pyi b/python/helpers/typeshed/stdlib/2and3/math.pyi index aa8b191ae0a4..7e2686c02f8d 100644 --- a/python/helpers/typeshed/stdlib/2and3/math.pyi +++ b/python/helpers/typeshed/stdlib/2and3/math.pyi @@ -13,71 +13,71 @@ if sys.version_info >= (3, 5): if sys.version_info >= (3, 6): tau: float -def acos(x: SupportsFloat) -> float: ... -def acosh(x: SupportsFloat) -> float: ... -def asin(x: SupportsFloat) -> float: ... -def asinh(x: SupportsFloat) -> float: ... -def atan(x: SupportsFloat) -> float: ... -def atan2(y: SupportsFloat, x: SupportsFloat) -> float: ... -def atanh(x: SupportsFloat) -> float: ... +def acos(__x: SupportsFloat) -> float: ... +def acosh(__x: SupportsFloat) -> float: ... +def asin(__x: SupportsFloat) -> float: ... +def asinh(__x: SupportsFloat) -> float: ... +def atan(__x: SupportsFloat) -> float: ... +def atan2(__y: SupportsFloat, __x: SupportsFloat) -> float: ... +def atanh(__x: SupportsFloat) -> float: ... if sys.version_info >= (3,): - def ceil(x: SupportsFloat) -> int: ... + def ceil(__x: SupportsFloat) -> int: ... else: - def ceil(x: SupportsFloat) -> float: ... -def copysign(x: SupportsFloat, y: SupportsFloat) -> float: ... -def cos(x: SupportsFloat) -> float: ... -def cosh(x: SupportsFloat) -> float: ... -def degrees(x: SupportsFloat) -> float: ... + def ceil(__x: SupportsFloat) -> float: ... +def copysign(__x: SupportsFloat, __y: SupportsFloat) -> float: ... +def cos(__x: SupportsFloat) -> float: ... +def cosh(__x: SupportsFloat) -> float: ... +def degrees(__x: SupportsFloat) -> float: ... if sys.version_info >= (3, 8): def dist(__p: Iterable[SupportsFloat], __q: Iterable[SupportsFloat]) -> float: ... -def erf(x: SupportsFloat) -> float: ... -def erfc(x: SupportsFloat) -> float: ... -def exp(x: SupportsFloat) -> float: ... -def expm1(x: SupportsFloat) -> float: ... -def fabs(x: SupportsFloat) -> float: ... -def factorial(x: SupportsInt) -> int: ... +def erf(__x: SupportsFloat) -> float: ... +def erfc(__x: SupportsFloat) -> float: ... +def exp(__x: SupportsFloat) -> float: ... +def expm1(__x: SupportsFloat) -> float: ... +def fabs(__x: SupportsFloat) -> float: ... +def factorial(__x: SupportsInt) -> int: ... if sys.version_info >= (3,): - def floor(x: SupportsFloat) -> int: ... + def floor(__x: SupportsFloat) -> int: ... else: - def floor(x: SupportsFloat) -> float: ... -def fmod(x: SupportsFloat, y: SupportsFloat) -> float: ... -def frexp(x: SupportsFloat) -> Tuple[float, int]: ... -def fsum(iterable: Iterable[float]) -> float: ... -def gamma(x: SupportsFloat) -> float: ... + def floor(__x: SupportsFloat) -> float: ... +def fmod(__x: SupportsFloat, __y: SupportsFloat) -> float: ... +def frexp(__x: SupportsFloat) -> Tuple[float, int]: ... +def fsum(__seq: Iterable[float]) -> float: ... +def gamma(__x: SupportsFloat) -> float: ... if sys.version_info >= (3, 5): - def gcd(a: int, b: int) -> int: ... + def gcd(__x: int, __y: int) -> int: ... if sys.version_info >= (3, 8): def hypot(*coordinates: SupportsFloat) -> float: ... else: def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... if sys.version_info >= (3, 5): - def isclose(a: SupportsFloat, b: SupportsFloat, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... -def isinf(x: SupportsFloat) -> bool: ... + def isclose(a: SupportsFloat, b: SupportsFloat, *, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... +def isinf(__x: SupportsFloat) -> bool: ... if sys.version_info >= (3,): - def isfinite(x: SupportsFloat) -> bool: ... -def isnan(x: SupportsFloat) -> bool: ... + def isfinite(__x: SupportsFloat) -> bool: ... +def isnan(__x: SupportsFloat) -> bool: ... if sys.version_info >= (3, 8): def isqrt(__n: int) -> int: ... -def ldexp(x: SupportsFloat, i: int) -> float: ... -def lgamma(x: SupportsFloat) -> float: ... +def ldexp(__x: SupportsFloat, __i: int) -> float: ... +def lgamma(__x: SupportsFloat) -> float: ... def log(x: SupportsFloat, base: SupportsFloat = ...) -> float: ... -def log10(x: SupportsFloat) -> float: ... -def log1p(x: SupportsFloat) -> float: ... +def log10(__x: SupportsFloat) -> float: ... +def log1p(__x: SupportsFloat) -> float: ... if sys.version_info >= (3, 3): - def log2(x: SupportsFloat) -> float: ... -def modf(x: SupportsFloat) -> Tuple[float, float]: ... -def pow(x: SupportsFloat, y: SupportsFloat) -> float: ... + def log2(__x: SupportsFloat) -> float: ... +def modf(__x: SupportsFloat) -> Tuple[float, float]: ... +def pow(__x: SupportsFloat, __y: SupportsFloat) -> float: ... if sys.version_info >= (3, 8): @overload def prod(__iterable: Iterable[int], *, start: int = ...) -> int: ... # type: ignore @overload def prod(__iterable: Iterable[SupportsFloat], *, start: SupportsFloat = ...) -> float: ... -def radians(x: SupportsFloat) -> float: ... +def radians(__x: SupportsFloat) -> float: ... if sys.version_info >= (3, 7): - def remainder(x: SupportsFloat, y: SupportsFloat) -> float: ... -def sin(x: SupportsFloat) -> float: ... -def sinh(x: SupportsFloat) -> float: ... -def sqrt(x: SupportsFloat) -> float: ... -def tan(x: SupportsFloat) -> float: ... -def tanh(x: SupportsFloat) -> float: ... -def trunc(x: SupportsFloat) -> int: ... + def remainder(__x: SupportsFloat, __y: SupportsFloat) -> float: ... +def sin(__x: SupportsFloat) -> float: ... +def sinh(__x: SupportsFloat) -> float: ... +def sqrt(__x: SupportsFloat) -> float: ... +def tan(__x: SupportsFloat) -> float: ... +def tanh(__x: SupportsFloat) -> float: ... +def trunc(__x: SupportsFloat) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/socket.pyi b/python/helpers/typeshed/stdlib/2and3/socket.pyi index ec8534166060..49b99906cf6b 100644 --- a/python/helpers/typeshed/stdlib/2and3/socket.pyi +++ b/python/helpers/typeshed/stdlib/2and3/socket.pyi @@ -628,8 +628,10 @@ class socket: def getblocking(self) -> bool: ... def gettimeout(self) -> Optional[float]: ... - if sys.platform == 'win32': - def ioctl(self, control: object, option: Tuple[int, int, int]) -> None: ... + if sys.platform == 'win32' and sys.version_info >= (3, 6): + def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ... + elif sys.platform == 'win32': + def ioctl(self, control: int, option: Union[int, Tuple[int, int, int]]) -> None: ... if sys.version_info >= (3, 5): def listen(self, __backlog: int = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/sqlite3/dbapi2.pyi b/python/helpers/typeshed/stdlib/2and3/sqlite3/dbapi2.pyi index 45c5c2106443..021e56ee3ce0 100644 --- a/python/helpers/typeshed/stdlib/2and3/sqlite3/dbapi2.pyi +++ b/python/helpers/typeshed/stdlib/2and3/sqlite3/dbapi2.pyi @@ -129,7 +129,10 @@ class Connection(object): def commit(self) -> None: ... def create_aggregate(self, name: str, num_params: int, aggregate_class: type) -> None: ... def create_collation(self, name: str, callable: Any) -> None: ... - def create_function(self, name: str, num_params: int, func: Any) -> None: ... + if sys.version_info >= (3, 8): + def create_function(self, name: str, num_params: int, func: Any, *, deterministic: bool = ...) -> None: ... + else: + def create_function(self, name: str, num_params: int, func: Any) -> None: ... def cursor(self, cursorClass: Optional[type] = ...) -> Cursor: ... def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ... # TODO: please check in executemany() if seq_of_parameters type is possible like this @@ -200,70 +203,73 @@ class NotSupportedError(DatabaseError): ... class OperationalError(DatabaseError): ... -class OptimizedUnicode(object): - maketrans: Any - def __init__(self, *args, **kwargs): ... - def capitalize(self, *args, **kwargs): ... - def casefold(self, *args, **kwargs): ... - def center(self, *args, **kwargs): ... - def count(self, *args, **kwargs): ... - def encode(self, *args, **kwargs): ... - def endswith(self, *args, **kwargs): ... - def expandtabs(self, *args, **kwargs): ... - def find(self, *args, **kwargs): ... - def format(self, *args, **kwargs): ... - def format_map(self, *args, **kwargs): ... - def index(self, *args, **kwargs): ... - def isalnum(self, *args, **kwargs): ... - def isalpha(self, *args, **kwargs): ... - def isdecimal(self, *args, **kwargs): ... - def isdigit(self, *args, **kwargs): ... - def isidentifier(self, *args, **kwargs): ... - def islower(self, *args, **kwargs): ... - def isnumeric(self, *args, **kwargs): ... - def isprintable(self, *args, **kwargs): ... - def isspace(self, *args, **kwargs): ... - def istitle(self, *args, **kwargs): ... - def isupper(self, *args, **kwargs): ... - def join(self, *args, **kwargs): ... - def ljust(self, *args, **kwargs): ... - def lower(self, *args, **kwargs): ... - def lstrip(self, *args, **kwargs): ... - def partition(self, *args, **kwargs): ... - def replace(self, *args, **kwargs): ... - def rfind(self, *args, **kwargs): ... - def rindex(self, *args, **kwargs): ... - def rjust(self, *args, **kwargs): ... - def rpartition(self, *args, **kwargs): ... - def rsplit(self, *args, **kwargs): ... - def rstrip(self, *args, **kwargs): ... - def split(self, *args, **kwargs): ... - def splitlines(self, *args, **kwargs): ... - def startswith(self, *args, **kwargs): ... - def strip(self, *args, **kwargs): ... - def swapcase(self, *args, **kwargs): ... - def title(self, *args, **kwargs): ... - def translate(self, *args, **kwargs): ... - def upper(self, *args, **kwargs): ... - def zfill(self, *args, **kwargs): ... - def __add__(self, other): ... - def __contains__(self, *args, **kwargs): ... - def __eq__(self, other): ... - def __format__(self, *args, **kwargs): ... - def __ge__(self, other): ... - def __getitem__(self, index): ... - def __getnewargs__(self, *args, **kwargs): ... - def __gt__(self, other): ... - def __hash__(self): ... - def __iter__(self): ... - def __le__(self, other): ... - def __len__(self, *args, **kwargs): ... - def __lt__(self, other): ... - def __mod__(self, other): ... - def __mul__(self, other): ... - def __ne__(self, other): ... - def __rmod__(self, other): ... - def __rmul__(self, other): ... +if sys.version_info >= (3,): + OptimizedUnicode = str +else: + class OptimizedUnicode(object): + maketrans: Any + def __init__(self, *args, **kwargs): ... + def capitalize(self, *args, **kwargs): ... + def casefold(self, *args, **kwargs): ... + def center(self, *args, **kwargs): ... + def count(self, *args, **kwargs): ... + def encode(self, *args, **kwargs): ... + def endswith(self, *args, **kwargs): ... + def expandtabs(self, *args, **kwargs): ... + def find(self, *args, **kwargs): ... + def format(self, *args, **kwargs): ... + def format_map(self, *args, **kwargs): ... + def index(self, *args, **kwargs): ... + def isalnum(self, *args, **kwargs): ... + def isalpha(self, *args, **kwargs): ... + def isdecimal(self, *args, **kwargs): ... + def isdigit(self, *args, **kwargs): ... + def isidentifier(self, *args, **kwargs): ... + def islower(self, *args, **kwargs): ... + def isnumeric(self, *args, **kwargs): ... + def isprintable(self, *args, **kwargs): ... + def isspace(self, *args, **kwargs): ... + def istitle(self, *args, **kwargs): ... + def isupper(self, *args, **kwargs): ... + def join(self, *args, **kwargs): ... + def ljust(self, *args, **kwargs): ... + def lower(self, *args, **kwargs): ... + def lstrip(self, *args, **kwargs): ... + def partition(self, *args, **kwargs): ... + def replace(self, *args, **kwargs): ... + def rfind(self, *args, **kwargs): ... + def rindex(self, *args, **kwargs): ... + def rjust(self, *args, **kwargs): ... + def rpartition(self, *args, **kwargs): ... + def rsplit(self, *args, **kwargs): ... + def rstrip(self, *args, **kwargs): ... + def split(self, *args, **kwargs): ... + def splitlines(self, *args, **kwargs): ... + def startswith(self, *args, **kwargs): ... + def strip(self, *args, **kwargs): ... + def swapcase(self, *args, **kwargs): ... + def title(self, *args, **kwargs): ... + def translate(self, *args, **kwargs): ... + def upper(self, *args, **kwargs): ... + def zfill(self, *args, **kwargs): ... + def __add__(self, other): ... + def __contains__(self, *args, **kwargs): ... + def __eq__(self, other): ... + def __format__(self, *args, **kwargs): ... + def __ge__(self, other): ... + def __getitem__(self, index): ... + def __getnewargs__(self, *args, **kwargs): ... + def __gt__(self, other): ... + def __hash__(self): ... + def __iter__(self): ... + def __le__(self, other): ... + def __len__(self, *args, **kwargs): ... + def __lt__(self, other): ... + def __mod__(self, other): ... + def __mul__(self, other): ... + def __ne__(self, other): ... + def __rmod__(self, other): ... + def __rmul__(self, other): ... class PrepareProtocol(object): def __init__(self, *args, **kwargs): ... diff --git a/python/helpers/typeshed/stdlib/2and3/ssl.pyi b/python/helpers/typeshed/stdlib/2and3/ssl.pyi index 48897dbb9787..1737f3dbc510 100644 --- a/python/helpers/typeshed/stdlib/2and3/ssl.pyi +++ b/python/helpers/typeshed/stdlib/2and3/ssl.pyi @@ -68,15 +68,26 @@ def create_default_context( cadata: Union[Text, bytes, None] = ..., ) -> SSLContext: ... -def _create_unverified_context(protocol: int = ..., *, - cert_reqs: int = ..., - check_hostname: bool = ..., - purpose: Any = ..., - certfile: Optional[str] = ..., - keyfile: Optional[str] = ..., - cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[Text, bytes, None] = ...) -> SSLContext: ... +if sys.version_info >= (3, 7): + def _create_unverified_context(protocol: int = ..., *, + cert_reqs: int = ..., + check_hostname: bool = ..., + purpose: Any = ..., + certfile: Optional[str] = ..., + keyfile: Optional[str] = ..., + cafile: Optional[str] = ..., + capath: Optional[str] = ..., + cadata: Union[Text, bytes, None] = ...) -> SSLContext: ... +else: + def _create_unverified_context(protocol: int = ..., *, + cert_reqs: Optional[int] = ..., + check_hostname: bool = ..., + purpose: Any = ..., + certfile: Optional[str] = ..., + keyfile: Optional[str] = ..., + cafile: Optional[str] = ..., + capath: Optional[str] = ..., + cadata: Union[Text, bytes, None] = ...) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] if sys.version_info >= (3, 3): @@ -267,8 +278,10 @@ class SSLContext: sni_callback: Optional[Callable[[SSLObject, str, SSLContext], Union[None, int]]] sslobject_class: Type[SSLObject] def set_npn_protocols(self, protocols: List[str]) -> None: ... - def set_servername_callback(self, - server_name_callback: Optional[_SrvnmeCbType]) -> None: ... + if sys.version_info >= (3, 7): + def set_servername_callback(self, server_name_callback: Optional[_SrvnmeCbType]) -> None: ... + else: + def set_servername_callback(self, __method: Optional[_SrvnmeCbType]) -> None: ... def load_dh_params(self, dhfile: str) -> None: ... def set_ecdh_curve(self, curve_name: str) -> None: ... def wrap_socket(self, sock: socket.socket, server_side: bool = ..., diff --git a/python/helpers/typeshed/stdlib/2and3/threading.pyi b/python/helpers/typeshed/stdlib/2and3/threading.pyi index ca1b0fd200a8..b10333543595 100644 --- a/python/helpers/typeshed/stdlib/2and3/threading.pyi +++ b/python/helpers/typeshed/stdlib/2and3/threading.pyi @@ -1,4 +1,3 @@ -# Stubs for threading from typing import ( Any, Callable, Iterable, List, Mapping, Optional, Tuple, Type, Union, @@ -14,6 +13,8 @@ _PF = Callable[[FrameType, str, Any], None] _T = TypeVar('_T') +__all__: List[str] + def active_count() -> int: ... if sys.version_info < (3,): def activeCount() -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi index 025b47493266..50e3a41b5618 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi @@ -104,34 +104,34 @@ class Element(MutableSequence[Element]): text: Optional[_str_result_type] tail: Optional[_str_result_type] def __init__(self, tag: Union[_str_argument_type, Callable[..., Element]], attrib: Dict[_str_argument_type, _str_argument_type] = ..., **extra: _str_argument_type) -> None: ... - def append(self, subelement: Element) -> None: ... + def append(self, __subelement: Element) -> None: ... def clear(self) -> None: ... def copy(self) -> Element: ... - def extend(self, elements: Iterable[Element]) -> None: ... + def extend(self, __elements: Iterable[Element]) -> None: ... def find(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Optional[Element]: ... def findall(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> List[Element]: ... @overload - def findtext(self, path: _str_argument_type, *, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Optional[_str_result_type]: ... + def findtext(self, path: _str_argument_type, default: None = ..., namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Optional[_str_result_type]: ... @overload def findtext(self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Union[_T, _str_result_type]: ... @overload - def get(self, key: _str_argument_type) -> Optional[_str_result_type]: ... + def get(self, key: _str_argument_type, default: None = ...) -> Optional[_str_result_type]: ... @overload def get(self, key: _str_argument_type, default: _T) -> Union[_str_result_type, _T]: ... def getchildren(self) -> List[Element]: ... def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... if sys.version_info >= (3, 2): - def insert(self, index: int, subelement: Element) -> None: ... + def insert(self, __index: int, __subelement: Element) -> None: ... else: - def insert(self, index: int, element: Element) -> None: ... + def insert(self, __index: int, __element: Element) -> None: ... def items(self) -> ItemsView[_str_result_type, _str_result_type]: ... def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... def iterfind(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> List[Element]: ... def itertext(self) -> Generator[_str_result_type, None, None]: ... def keys(self) -> KeysView[_str_result_type]: ... - def makeelement(self, tag: _str_argument_type, attrib: Dict[_str_argument_type, _str_argument_type]) -> Element: ... - def remove(self, subelement: Element) -> None: ... - def set(self, key: _str_argument_type, value: _str_argument_type) -> None: ... + def makeelement(self, __tag: _str_argument_type, __attrib: Dict[_str_argument_type, _str_argument_type]) -> Element: ... + def remove(self, __subelement: Element) -> None: ... + def set(self, __key: _str_argument_type, __value: _str_argument_type) -> None: ... def __bool__(self) -> bool: ... def __delitem__(self, i: Union[int, slice]) -> None: ... @overload @@ -163,7 +163,7 @@ class ElementTree: def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... def find(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Optional[Element]: ... @overload - def findtext(self, path: _str_argument_type, *, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Optional[_str_result_type]: ... + def findtext(self, path: _str_argument_type, default: None = ..., namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Optional[_str_result_type]: ... @overload def findtext(self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Union[_T, _str_result_type]: ... def findall(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> List[Element]: ... @@ -224,9 +224,9 @@ _ElementFactory = Callable[[Any, Dict[Any, Any]], Element] class TreeBuilder: def __init__(self, element_factory: Optional[_ElementFactory] = ...) -> None: ... def close(self) -> Element: ... - def data(self, data: _parser_input_type) -> None: ... - def start(self, tag: _parser_input_type, attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ... - def end(self, tag: _parser_input_type) -> Element: ... + def data(self, __data: _parser_input_type) -> None: ... + def start(self, __tag: _parser_input_type, __attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ... + def end(self, __tag: _parser_input_type) -> Element: ... if sys.version_info >= (3, 8): class C14NWriterTarget: @@ -254,6 +254,6 @@ class XMLParser: def __init__(self, *, target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ... else: def __init__(self, html: int = ..., target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ... - def doctype(self, name: str, pubid: str, system: str) -> None: ... + def doctype(self, __name: str, __pubid: str, __system: str) -> None: ... def close(self) -> Element: ... - def feed(self, data: _parser_input_type) -> None: ... + def feed(self, __data: _parser_input_type) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/__init__.pyi b/python/helpers/typeshed/stdlib/3/asyncio/__init__.pyi index 57747efbd7db..8ba093616e53 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/__init__.pyi @@ -125,9 +125,10 @@ if sys.version_info >= (3, 8): TimeoutError as TimeoutError, ) else: - from asyncio.events import ( - SendfileNotAvailableError as SendfileNotAvailableError - ) + if sys.version_info >= (3, 7): + from asyncio.events import ( + SendfileNotAvailableError as SendfileNotAvailableError + ) from asyncio.futures import ( CancelledError as CancelledError, TimeoutError as TimeoutError, diff --git a/python/helpers/typeshed/stdlib/3/asyncio/base_events.pyi b/python/helpers/typeshed/stdlib/3/asyncio/base_events.pyi index 86a8052850a8..af3b87580a49 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/base_events.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/base_events.pyi @@ -90,7 +90,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[str] = ..., + local_addr: Optional[Tuple[str, int]] = ..., server_hostname: Optional[str] = ..., ssl_handshake_timeout: Optional[float] = ..., happy_eyeballs_delay: Optional[float] = ..., @@ -118,7 +118,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): @overload async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., - sock: None = ..., local_addr: Optional[str] = ..., server_hostname: Optional[str] = ..., + sock: None = ..., local_addr: Optional[Tuple[str, int]] = ..., server_hostname: Optional[str] = ..., ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ... @overload async def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *, @@ -129,7 +129,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): @overload async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...) -> _TransProtPair: ... + local_addr: Optional[Tuple[str, int]] = ..., server_hostname: Optional[str] = ...) -> _TransProtPair: ... @overload async def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *, ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket, diff --git a/python/helpers/typeshed/stdlib/3/asyncio/events.pyi b/python/helpers/typeshed/stdlib/3/asyncio/events.pyi index 70d04051a4f7..d4e0e5762dcf 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/events.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/events.pyi @@ -125,7 +125,7 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[str] = ..., + local_addr: Optional[Tuple[str, int]] = ..., server_hostname: Optional[str] = ..., ssl_handshake_timeout: Optional[float] = ..., happy_eyeballs_delay: Optional[float] = ..., @@ -155,7 +155,7 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., - sock: None = ..., local_addr: Optional[str] = ..., server_hostname: Optional[str] = ..., + sock: None = ..., local_addr: Optional[Tuple[str, int]] = ..., server_hostname: Optional[str] = ..., ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ... @overload @abstractmethod @@ -168,7 +168,7 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *, ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...) -> _TransProtPair: ... + local_addr: Optional[Tuple[str, int]] = ..., server_hostname: Optional[str] = ...) -> _TransProtPair: ... @overload @abstractmethod async def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *, @@ -335,6 +335,5 @@ def _get_running_loop() -> AbstractEventLoop: ... if sys.version_info >= (3, 7): def get_running_loop() -> AbstractEventLoop: ... - -if sys.version_info < (3, 8): - class SendfileNotAvailableError(RuntimeError): ... + if sys.version_info < (3, 8): + class SendfileNotAvailableError(RuntimeError): ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/futures.pyi b/python/helpers/typeshed/stdlib/3/asyncio/futures.pyi index 824364a24531..c9a2ac44a18d 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/futures.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/futures.pyi @@ -17,13 +17,14 @@ if sys.version_info >= (3, 7): _T = TypeVar('_T') _S = TypeVar('_S') -class _TracebackLogger: - exc: BaseException - tb: List[str] - def __init__(self, exc: Any, loop: AbstractEventLoop) -> None: ... - def activate(self) -> None: ... - def clear(self) -> None: ... - def __del__(self) -> None: ... +if sys.version_info < (3, 7): + class _TracebackLogger: + exc: BaseException + tb: List[str] + def __init__(self, exc: Any, loop: AbstractEventLoop) -> None: ... + def activate(self) -> None: ... + def clear(self) -> None: ... + def __del__(self) -> None: ... def isfuture(obj: object) -> bool: ... @@ -32,7 +33,8 @@ class Future(Awaitable[_T], Iterable[_T]): _exception: BaseException _blocking = False _log_traceback = False - _tb_logger: Type[_TracebackLogger] + if sys.version_info < (3, 6): + _tb_logger: Type[_TracebackLogger] def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ... def __repr__(self) -> str: ... def __del__(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/tasks.pyi b/python/helpers/typeshed/stdlib/3/asyncio/tasks.pyi index 28614687ab74..9bb5a5b4e2cc 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/tasks.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/tasks.pyi @@ -115,7 +115,8 @@ class Task(Future[_T], Generic[_T]): def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ... def cancel(self) -> bool: ... def _step(self, value: Any = ..., exc: Exception = ...) -> None: ... - def _wakeup(self, future: Future[Any]) -> None: ... + if sys.version_info < (3, 7): + def _wakeup(self, future: Future[Any]) -> None: ... if sys.version_info >= (3, 7): def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ... diff --git a/python/helpers/typeshed/stdlib/3/asyncio/transports.pyi b/python/helpers/typeshed/stdlib/3/asyncio/transports.pyi index df80beb4eda9..a0b0fdd8b07a 100644 --- a/python/helpers/typeshed/stdlib/3/asyncio/transports.pyi +++ b/python/helpers/typeshed/stdlib/3/asyncio/transports.pyi @@ -4,7 +4,7 @@ from asyncio.protocols import BaseProtocol from asyncio.events import AbstractEventLoop class BaseTransport: - def __init__(self, extra: Mapping[Any, Any] = ...) -> None: ... + def __init__(self, extra: Optional[Mapping[Any, Any]] = ...) -> None: ... def get_extra_info(self, name: Any, default: Any = ...) -> Any: ... def is_closing(self) -> bool: ... def close(self) -> None: ... @@ -37,8 +37,8 @@ class DatagramTransport(BaseTransport): class SubprocessTransport(BaseTransport): def get_pid(self) -> int: ... - def get_returncode(self) -> int: ... - def get_pipe_transport(self, fd: int) -> BaseTransport: ... + def get_returncode(self) -> Optional[int]: ... + def get_pipe_transport(self, fd: int) -> Optional[BaseTransport]: ... def send_signal(self, signal: int) -> int: ... def terminate(self) -> None: ... def kill(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/builtins.pyi b/python/helpers/typeshed/stdlib/3/builtins.pyi index 3909cdaceb61..54c36b432d08 100644 --- a/python/helpers/typeshed/stdlib/3/builtins.pyi +++ b/python/helpers/typeshed/stdlib/3/builtins.pyi @@ -300,7 +300,7 @@ class str(Sequence[str], _str_base): def capitalize(self) -> str: ... if sys.version_info >= (3, 3): def casefold(self) -> str: ... - def center(self, width: int, fillchar: str = ...) -> str: ... + def center(self, __width: int, __fillchar: str = ...) -> str: ... def count(self, x: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... def endswith(self, suffix: Union[Text, Tuple[Text, ...]], start: Optional[int] = ..., @@ -323,34 +323,34 @@ class str(Sequence[str], _str_base): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[str]) -> str: ... - def ljust(self, width: int, fillchar: str = ...) -> str: ... + def join(self, __iterable: Iterable[str]) -> str: ... + def ljust(self, __width: int, __fillchar: str = ...) -> str: ... def lower(self) -> str: ... - def lstrip(self, chars: Optional[str] = ...) -> str: ... - def partition(self, sep: str) -> Tuple[str, str, str]: ... - def replace(self, old: str, new: str, count: int = ...) -> str: ... + def lstrip(self, __chars: Optional[str] = ...) -> str: ... + def partition(self, __sep: str) -> Tuple[str, str, str]: ... + def replace(self, __old: str, __new: str, __count: int = ...) -> str: ... def rfind(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rindex(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... - def rjust(self, width: int, fillchar: str = ...) -> str: ... - def rpartition(self, sep: str) -> Tuple[str, str, str]: ... + def rjust(self, __width: int, __fillchar: str = ...) -> str: ... + def rpartition(self, __sep: str) -> Tuple[str, str, str]: ... def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... - def rstrip(self, chars: Optional[str] = ...) -> str: ... + def rstrip(self, __chars: Optional[str] = ...) -> str: ... def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith(self, prefix: Union[Text, Tuple[Text, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... - def strip(self, chars: Optional[str] = ...) -> str: ... + def strip(self, __chars: Optional[str] = ...) -> str: ... def swapcase(self) -> str: ... def title(self) -> str: ... - def translate(self, table: Union[Mapping[int, Union[int, str, None]], Sequence[Union[int, str, None]]]) -> str: ... + def translate(self, __table: Union[Mapping[int, Union[int, str, None]], Sequence[Union[int, str, None]]]) -> str: ... def upper(self) -> str: ... - def zfill(self, width: int) -> str: ... + def zfill(self, __width: int) -> str: ... @staticmethod @overload - def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ... + def maketrans(__x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ... @staticmethod @overload - def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Union[int, None]]: ... + def maketrans(__x: str, __y: str, __z: Optional[str] = ...) -> Dict[int, Union[int, None]]: ... def __add__(self, s: str) -> str: ... # Incompatible with Sequence.__contains__ @@ -386,7 +386,7 @@ class bytes(ByteString): @overload def __init__(self, o: SupportsBytes) -> None: ... def capitalize(self) -> bytes: ... - def center(self, width: int, fillchar: bytes = ...) -> bytes: ... + def center(self, __width: int, __fillchar: bytes = ...) -> bytes: ... def count(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... @@ -406,18 +406,18 @@ class bytes(ByteString): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[Union[ByteString, memoryview]]) -> bytes: ... - def ljust(self, width: int, fillchar: bytes = ...) -> bytes: ... + def join(self, __iterable_of_bytes: Iterable[Union[ByteString, memoryview]]) -> bytes: ... + def ljust(self, __width: int, __fillchar: bytes = ...) -> bytes: ... def lower(self) -> bytes: ... - def lstrip(self, chars: Optional[bytes] = ...) -> bytes: ... - def partition(self, sep: bytes) -> Tuple[bytes, bytes, bytes]: ... - def replace(self, old: bytes, new: bytes, count: int = ...) -> bytes: ... + def lstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ... + def partition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... + def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytes: ... def rfind(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... def rindex(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... - def rjust(self, width: int, fillchar: bytes = ...) -> bytes: ... - def rpartition(self, sep: bytes) -> Tuple[bytes, bytes, bytes]: ... + def rjust(self, __width: int, __fillchar: bytes = ...) -> bytes: ... + def rpartition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ... - def rstrip(self, chars: Optional[bytes] = ...) -> bytes: ... + def rstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ... def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ... def splitlines(self, keepends: bool = ...) -> List[bytes]: ... def startswith( @@ -426,12 +426,12 @@ class bytes(ByteString): start: Optional[int] = ..., end: Optional[int] = ..., ) -> bool: ... - def strip(self, chars: Optional[bytes] = ...) -> bytes: ... + def strip(self, __bytes: Optional[bytes] = ...) -> bytes: ... def swapcase(self) -> bytes: ... def title(self) -> bytes: ... - def translate(self, table: Optional[bytes], delete: bytes = ...) -> bytes: ... + def translate(self, __table: Optional[bytes], delete: bytes = ...) -> bytes: ... def upper(self) -> bytes: ... - def zfill(self, width: int) -> bytes: ... + def zfill(self, __width: int) -> bytes: ... @classmethod def fromhex(cls, s: str) -> bytes: ... @classmethod @@ -473,17 +473,17 @@ class bytearray(MutableSequence[int], ByteString): @overload def __init__(self, length: int) -> None: ... def capitalize(self) -> bytearray: ... - def center(self, width: int, fillchar: bytes = ...) -> bytearray: ... - def count(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... + def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... + def count(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def copy(self) -> bytearray: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... - def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... + def endswith(self, __suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... - def find(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... + def find(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... if sys.version_info >= (3, 5): def hex(self) -> str: ... - def index(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... - def insert(self, index: int, object: int) -> None: ... + def index(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def insert(self, __index: int, __item: int) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... if sys.version_info >= (3, 7): @@ -493,36 +493,36 @@ class bytearray(MutableSequence[int], ByteString): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[Union[ByteString, memoryview]]) -> bytearray: ... - def ljust(self, width: int, fillchar: bytes = ...) -> bytearray: ... + def join(self, __iterable_of_bytes: Iterable[Union[ByteString, memoryview]]) -> bytearray: ... + def ljust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def lower(self) -> bytearray: ... - def lstrip(self, chars: Optional[bytes] = ...) -> bytearray: ... - def partition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... - def replace(self, old: bytes, new: bytes, count: int = ...) -> bytearray: ... - def rfind(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... - def rindex(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ... - def rjust(self, width: int, fillchar: bytes = ...) -> bytearray: ... - def rpartition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def lstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... + def partition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... + def rfind(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def rindex(self, __sub: Union[bytes, int], __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... + def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... - def rstrip(self, chars: Optional[bytes] = ...) -> bytearray: ... + def rstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( self, - prefix: Union[bytes, Tuple[bytes, ...]], - start: Optional[int] = ..., - end: Optional[int] = ..., + __prefix: Union[bytes, Tuple[bytes, ...]], + __start: Optional[int] = ..., + __end: Optional[int] = ..., ) -> bool: ... - def strip(self, chars: Optional[bytes] = ...) -> bytearray: ... + def strip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... def title(self) -> bytearray: ... - def translate(self, table: Optional[bytes], delete: bytes = ...) -> bytearray: ... + def translate(self, __table: Optional[bytes], delete: bytes = ...) -> bytearray: ... def upper(self) -> bytearray: ... - def zfill(self, width: int) -> bytearray: ... + def zfill(self, __width: int) -> bytearray: ... @staticmethod - def fromhex(s: str) -> bytearray: ... + def fromhex(__string: str) -> bytearray: ... @classmethod - def maketrans(cls, frm: bytes, to: bytes) -> bytes: ... + def maketrans(cls, __frm: bytes, __to: bytes) -> bytes: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[int]: ... @@ -567,6 +567,7 @@ class memoryview(Sized, Container[_mv_container_type]): readonly: bool ndim: int + obj: Union[bytes, bytearray] c_contiguous: bool f_contiguous: bool contiguous: bool @@ -574,6 +575,7 @@ class memoryview(Sized, Container[_mv_container_type]): def __init__(self, obj: Union[bytes, bytearray, memoryview]) -> None: ... def __enter__(self) -> memoryview: ... def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ... + def cast(self, format: str, shape: Union[List[int], Tuple[int]] = ...): ... @overload def __getitem__(self, i: int) -> _mv_container_type: ... @@ -660,11 +662,11 @@ class tuple(Sequence[_T_co], Generic[_T_co]): def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... - def count(self, x: Any) -> int: ... + def count(self, __value: Any) -> int: ... if sys.version_info >= (3, 5): - def index(self, x: Any, start: int = ..., end: int = ...) -> int: ... + def index(self, __value: Any, __start: int = ..., __stop: int = ...) -> int: ... else: - def index(self, x: Any) -> int: ... + def index(self, __value: Any) -> int: ... class function: # TODO not defined in builtins! @@ -681,13 +683,13 @@ class list(MutableSequence[_T], Generic[_T]): def __init__(self, iterable: Iterable[_T]) -> None: ... def clear(self) -> None: ... def copy(self) -> List[_T]: ... - def append(self, object: _T) -> None: ... - def extend(self, iterable: Iterable[_T]) -> None: ... - def pop(self, index: int = ...) -> _T: ... - def index(self, object: _T, start: int = ..., stop: int = ...) -> int: ... - def count(self, object: _T) -> int: ... - def insert(self, index: int, object: _T) -> None: ... - def remove(self, object: _T) -> None: ... + def append(self, __object: _T) -> None: ... + def extend(self, __iterable: Iterable[_T]) -> None: ... + def pop(self, __index: int = ...) -> _T: ... + def index(self, __value: _T, __start: int = ..., __stop: int = ...) -> int: ... + def count(self, __value: _T) -> int: ... + def insert(self, __index: int, __object: _T) -> None: ... + def remove(self, __value: _T) -> None: ... def reverse(self) -> None: ... def sort(self, *, key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...) -> None: ... @@ -731,7 +733,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def clear(self) -> None: ... def copy(self) -> Dict[_KT, _VT]: ... def popitem(self) -> Tuple[_KT, _VT]: ... - def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... + def setdefault(self, __key: _KT, __default: _VT = ...) -> _VT: ... @overload def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload @@ -743,10 +745,10 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def items(self) -> ItemsView[_KT, _VT]: ... @staticmethod @overload - def fromkeys(seq: Iterable[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method (mypy/issues#328) + def fromkeys(__iterable: Iterable[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method (mypy/issues#328) @staticmethod @overload - def fromkeys(seq: Iterable[_T], value: _S) -> Dict[_T, _S]: ... + def fromkeys(__iterable: Iterable[_T], __value: _S) -> Dict[_T, _S]: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... @@ -831,7 +833,7 @@ class range(Sequence[int]): @overload def __init__(self, start: int, stop: int, step: int = ...) -> None: ... def count(self, value: int) -> int: ... - def index(self, value: int, start: int = ..., stop: Optional[int] = ...) -> int: ... + def index(self, value: int) -> int: ... # type: ignore def __len__(self) -> int: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[int]: ... @@ -860,17 +862,17 @@ class property(object): NotImplemented: Any -def abs(__n: SupportsAbs[_T]) -> _T: ... -def all(__i: Iterable[object]) -> bool: ... -def any(__i: Iterable[object]) -> bool: ... -def ascii(__o: object) -> str: ... +def abs(__x: SupportsAbs[_T]) -> _T: ... +def all(__iterable: Iterable[object]) -> bool: ... +def any(__iterable: Iterable[object]) -> bool: ... +def ascii(__obj: object) -> str: ... def bin(__number: Union[int, _SupportsIndex]) -> str: ... if sys.version_info >= (3, 7): def breakpoint(*args: Any, **kws: Any) -> None: ... -def callable(__o: object) -> bool: ... -def chr(__code: int) -> str: ... +def callable(__obj: object) -> bool: ... +def chr(__i: int) -> str: ... if sys.version_info >= (3, 6): # This class is to be exported as PathLike from os, # but we define it here as _PathLike to avoid import cycle issues. @@ -881,25 +883,25 @@ if sys.version_info >= (3, 6): def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ... def copyright() -> None: ... def credits() -> None: ... -def delattr(__o: Any, __name: Text) -> None: ... +def delattr(__obj: Any, __name: Text) -> None: ... def dir(__o: object = ...) -> List[str]: ... _N2 = TypeVar('_N2', int, float) -def divmod(__a: _N2, __b: _N2) -> Tuple[_N2, _N2]: ... +def divmod(__x: _N2, __y: _N2) -> Tuple[_N2, _N2]: ... def eval(__source: Union[Text, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ...) -> Any: ... -def exec(__object: Union[str, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ...) -> Any: ... +def exec(__source: Union[str, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ...) -> Any: ... def exit(code: object = ...) -> NoReturn: ... @overload def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> Iterator[_T]: ... @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> Iterator[_T]: ... -def format(__o: object, __format_spec: str = ...) -> str: ... # TODO unicode +def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ... def globals() -> Dict[str, Any]: ... -def hasattr(__o: Any, __name: Text) -> bool: ... -def hash(__o: object) -> int: ... +def hasattr(__obj: Any, __name: Text) -> bool: ... +def hash(__obj: object) -> int: ... def help(*args: Any, **kwds: Any) -> None: ... -def hex(__i: Union[int, _SupportsIndex]) -> str: ... -def id(__o: object) -> int: ... +def hex(__number: Union[int, _SupportsIndex]) -> str: ... +def id(__obj: object) -> int: ... def input(__prompt: Any = ...) -> str: ... @overload def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... @@ -907,9 +909,9 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... -def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... -def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... -def len(__o: Sized) -> int: ... +def isinstance(__obj: object, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def len(__obj: Sized) -> int: ... def license() -> None: ... def locals() -> Dict[str, Any]: ... @overload @@ -960,7 +962,7 @@ def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ..., default: _V def next(__i: Iterator[_T]) -> _T: ... @overload def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... -def oct(__i: Union[int, _SupportsIndex]) -> str: ... +def oct(__number: Union[int, _SupportsIndex]) -> str: ... if sys.version_info >= (3, 6): def open(file: Union[str, bytes, int, _PathLike[Any]], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., @@ -978,20 +980,26 @@ def print( ) -> None: ... -@overload -def pow(__x: int, __y: int) -> Any: ... # The return type can be int or float, depending on y -@overload -def pow(__x: int, __y: int, __z: int) -> Any: ... -@overload -def pow(__x: float, __y: float) -> float: ... -@overload -def pow(__x: float, __y: float, __z: float) -> float: ... +if sys.version_info >= (3, 8): + @overload + def pow(base: int, exp: int, mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative + @overload + def pow(base: int, exp: int, mod: int) -> int: ... + @overload + def pow(base: float, exp: float, mod: None = ...) -> float: ... +else: + @overload + def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative + @overload + def pow(__base: int, __exp: int, __mod: int) -> int: ... + @overload + def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... def quit(code: object = ...) -> NoReturn: ... @overload def reversed(__object: Sequence[_T]) -> Iterator[_T]: ... @overload def reversed(__object: Reversible[_T]) -> Iterator[_T]: ... -def repr(__o: object) -> str: ... +def repr(__obj: object) -> str: ... @overload def round(number: float) -> int: ... @overload @@ -1004,7 +1012,7 @@ def round(number: SupportsRound[_T]) -> int: ... def round(number: SupportsRound[_T], ndigits: None) -> int: ... @overload def round(number: SupportsRound[_T], ndigits: int) -> _T: ... -def setattr(__object: Any, __name: Text, __value: Any) -> None: ... +def setattr(__obj: Any, __name: Text, __value: Any) -> None: ... def sorted(__iterable: Iterable[_T], *, key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ...) -> List[_T]: ... diff --git a/python/helpers/typeshed/stdlib/3/io.pyi b/python/helpers/typeshed/stdlib/3/io.pyi index d835219dd92b..4a79e7b60259 100644 --- a/python/helpers/typeshed/stdlib/3/io.pyi +++ b/python/helpers/typeshed/stdlib/3/io.pyi @@ -3,6 +3,7 @@ from typing import ( ) import builtins import codecs +import sys from mmap import mmap from types import TracebackType from typing import TypeVar @@ -102,7 +103,7 @@ class BytesIO(BinaryIO): # TODO should be the next line instead # def writelines(self, lines: List[Union[bytes, bytearray]]) -> None: ... def writelines(self, lines: Any) -> None: ... - def readline(self, size: int = ...) -> bytes: ... + def readline(self, __size: Optional[int] = ...) -> bytes: ... def __del__(self) -> None: ... closed: bool # copied from BufferedIOBase @@ -111,7 +112,10 @@ class BytesIO(BinaryIO): def write(self, b: Union[bytes, bytearray]) -> int: ... def readinto1(self, b: _bytearray_like) -> int: ... def read(self, size: Optional[int] = ...) -> bytes: ... - def read1(self, size: int = ...) -> bytes: ... + if sys.version_info >= (3, 7): + def read1(self, __size: Optional[int] = ...) -> bytes: ... + else: + def read1(self, __size: Optional[int]) -> bytes: ... class BufferedReader(BufferedIOBase): def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi b/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi index f797b548acc9..569e6e394500 100644 --- a/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi @@ -10,8 +10,10 @@ from multiprocessing.context import ( AuthenticationError as AuthenticationError, BaseContext, BufferTooShort as BufferTooShort, + DefaultContext, Process as Process, ProcessError as ProcessError, + SpawnContext, TimeoutError as TimeoutError, ) from multiprocessing.managers import SyncManager @@ -22,6 +24,13 @@ from multiprocessing.spawn import set_executable as set_executable if sys.version_info >= (3, 8): from multiprocessing.process import parent_process as parent_process + from typing import Literal +else: + from typing_extensions import Literal + +if sys.platform != "win32": + from multiprocessing.context import ForkContext, ForkServerContext + # N.B. The functions below are generated at runtime by partially applying # multiprocessing.context.BaseContext's methods, so the two signatures should @@ -79,6 +88,25 @@ def log_to_stderr(level: Optional[Union[str, int]] = ...) -> Logger: ... def Manager() -> SyncManager: ... def set_forkserver_preload(module_names: List[str]) -> None: ... def get_all_start_methods() -> List[str]: ... -def get_context(method: Optional[str] = ...) -> BaseContext: ... def get_start_method(allow_none: bool = ...) -> Optional[str]: ... def set_start_method(method: str, force: Optional[bool] = ...) -> None: ... + + +if sys.platform != "win32": + @overload + def get_context(method: None = ...) -> DefaultContext: ... + @overload + def get_context(method: Literal["spawn"]) -> SpawnContext: ... + @overload + def get_context(method: Literal["fork"]) -> ForkContext: ... + @overload + def get_context(method: Literal["forkserver"]) -> ForkServerContext: ... + @overload + def get_context(method: str) -> BaseContext: ... +else: + @overload + def get_context(method: None = ...) -> DefaultContext: ... + @overload + def get_context(method: Literal["spawn"]) -> SpawnContext: ... + @overload + def get_context(method: str) -> BaseContext: ... diff --git a/python/helpers/typeshed/stdlib/3/multiprocessing/context.pyi b/python/helpers/typeshed/stdlib/3/multiprocessing/context.pyi index 627c760f0fe3..49b4e8d3d30a 100644 --- a/python/helpers/typeshed/stdlib/3/multiprocessing/context.pyi +++ b/python/helpers/typeshed/stdlib/3/multiprocessing/context.pyi @@ -6,7 +6,12 @@ from multiprocessing import synchronize from multiprocessing import queues from multiprocessing.process import BaseProcess import sys -from typing import Any, Callable, Iterable, Optional, List, Mapping, Sequence, Type, Union +from typing import Any, Callable, Iterable, Optional, List, Mapping, Sequence, Type, Union, overload + +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal _LockLike = Union[synchronize.Lock, synchronize.RLock] @@ -19,6 +24,7 @@ class TimeoutError(ProcessError): ... class AuthenticationError(ProcessError): ... class BaseContext(object): + Process: Type[BaseProcess] ProcessError: Type[Exception] BufferTooShort: Type[Exception] TimeoutError: Type[Exception] @@ -96,7 +102,26 @@ class BaseContext(object): def allow_connection_pickling(self) -> None: ... def set_executable(self, executable: str) -> None: ... def set_forkserver_preload(self, module_names: List[str]) -> None: ... - def get_context(self, method: Optional[str] = ...) -> BaseContext: ... + + if sys.platform != "win32": + @overload + def get_context(self, method: None = ...) -> DefaultContext: ... + @overload + def get_context(self, method: Literal["spawn"]) -> SpawnContext: ... + @overload + def get_context(self, method: Literal["fork"]) -> ForkContext: ... + @overload + def get_context(self, method: Literal["forkserver"]) -> ForkServerContext: ... + @overload + def get_context(self, method: str) -> BaseContext: ... + else: + @overload + def get_context(self, method: None = ...) -> DefaultContext: ... + @overload + def get_context(self, method: Literal["spawn"]) -> SpawnContext: ... + @overload + def get_context(self, method: str) -> BaseContext: ... + def get_start_method(self, allow_none: bool = ...) -> str: ... def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ... @property @@ -114,7 +139,6 @@ class DefaultContext(BaseContext): Process: Type[multiprocessing.Process] def __init__(self, context: BaseContext) -> None: ... - def get_context(self, method: Optional[str] = ...) -> BaseContext: ... def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ... def get_start_method(self, allow_none: bool = ...) -> str: ... def get_all_start_methods(self) -> List[str]: ... diff --git a/python/helpers/typeshed/stdlib/3/os/__init__.pyi b/python/helpers/typeshed/stdlib/3/os/__init__.pyi index 777cefc33165..446812cc2254 100644 --- a/python/helpers/typeshed/stdlib/3/os/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/os/__init__.pyi @@ -270,17 +270,33 @@ else: if sys.platform != 'win32': - class statvfs_result: # Unix only - f_bsize: int - f_frsize: int - f_blocks: int - f_bfree: int - f_bavail: int - f_files: int - f_ffree: int - f_favail: int - f_flag: int - f_namemax: int + if sys.version_info >= (3, 7): + # f_fsid was added in https://github.com/python/cpython/pull/4571 + class statvfs_result(NamedTuple): # Unix only + f_bsize: int + f_frsize: int + f_blocks: int + f_bfree: int + f_bavail: int + f_files: int + f_ffree: int + f_favail: int + f_flag: int + f_namemax: int + f_fsid: int + else: + class statvfs_result(NamedTuple): # Unix only + f_bsize: int + f_frsize: int + f_blocks: int + f_bfree: int + f_bavail: int + f_files: int + f_ffree: int + f_favail: int + f_flag: int + f_namemax: int + # ----- os function stubs ----- if sys.version_info >= (3, 6): diff --git a/python/helpers/typeshed/stdlib/3/signal.pyi b/python/helpers/typeshed/stdlib/3/signal.pyi index dd457d8cc4ec..7cf810d6aef4 100644 --- a/python/helpers/typeshed/stdlib/3/signal.pyi +++ b/python/helpers/typeshed/stdlib/3/signal.pyi @@ -1,5 +1,6 @@ """Stub file for the 'signal' module.""" +import sys from enum import IntEnum from typing import Any, Callable, Tuple, Union, Optional, Iterable, Set from types import FrameType @@ -135,6 +136,10 @@ def alarm(time: int) -> int: ... def default_int_handler(signum: int, frame: FrameType) -> None: ... def getitimer(which: int) -> Tuple[float, float]: ... def getsignal(signalnum: _SIGNUM) -> _HANDLER: ... +if sys.version_info >= (3, 8): + def strsignal(signalnum: _SIGNUM) -> Optional[str]: ... + def valid_signals() -> Set[Signals]: ... + def raise_signal(signalnum: _SIGNUM) -> None: ... def pause() -> None: ... def pthread_kill(thread_id: int, signum: int) -> None: ... def pthread_sigmask(how: int, mask: Iterable[int]) -> Set[_SIGNUM]: ... diff --git a/python/helpers/typeshed/stdlib/3/subprocess.pyi b/python/helpers/typeshed/stdlib/3/subprocess.pyi index 2fd8b5ba724b..57585adbf9ba 100644 --- a/python/helpers/typeshed/stdlib/3/subprocess.pyi +++ b/python/helpers/typeshed/stdlib/3/subprocess.pyi @@ -832,9 +832,9 @@ class CalledProcessError(Exception): class Popen(Generic[AnyStr]): args: _CMD - stdin: IO[AnyStr] - stdout: IO[AnyStr] - stderr: IO[AnyStr] + stdin: Optional[IO[AnyStr]] + stdout: Optional[IO[AnyStr]] + stderr: Optional[IO[AnyStr]] pid: int returncode: int @@ -1156,7 +1156,10 @@ class Popen(Generic[AnyStr]): pass_fds: Any = ...) -> Popen[Any]: ... def poll(self) -> int: ... - def wait(self, timeout: Optional[float] = ...) -> int: ... + if sys.version_info >= (3, 7): + def wait(self, timeout: Optional[float] = ...) -> int: ... + else: + def wait(self, timeout: Optional[float] = ..., endtime: Optional[float] = ...) -> int: ... # Return str/bytes def communicate(self, input: Optional[AnyStr] = ..., diff --git a/python/helpers/typeshed/stdlib/3/sys.pyi b/python/helpers/typeshed/stdlib/3/sys.pyi index 3d17a55c9ae5..f78826c65f8a 100644 --- a/python/helpers/typeshed/stdlib/3/sys.pyi +++ b/python/helpers/typeshed/stdlib/3/sys.pyi @@ -28,8 +28,8 @@ builtin_module_names: Sequence[str] # actually a tuple of strings copyright: str # dllhandle = 0 # Windows only dont_write_bytecode: bool -__displayhook__: Any # contains the original value of displayhook -__excepthook__: Any # contains the original value of excepthook +displayhook: Callable[[object], Any] +excepthook: Callable[[Type[BaseException], BaseException, TracebackType], Any] exec_prefix: str executable: str float_repr_style: str @@ -131,9 +131,9 @@ def call_tracing(fn: Callable[..., _T], args: Any) -> _T: ... def _clear_type_cache() -> None: ... def _current_frames() -> Dict[int, Any]: ... def _debugmallocstats() -> None: ... -def displayhook(value: Optional[int]) -> None: ... -def excepthook(type_: Type[BaseException], value: BaseException, - traceback: TracebackType) -> None: ... +def __displayhook__(value: object) -> None: ... +def __excepthook__(type_: Type[BaseException], value: BaseException, + traceback: TracebackType) -> None: ... def exc_info() -> _OptExcInfo: ... # sys.exit() accepts an optional argument of anything printable def exit(arg: object = ...) -> NoReturn: ... diff --git a/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi b/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi index 01f0dbb16dfc..2580f76a33c9 100644 --- a/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi @@ -6,7 +6,7 @@ from types import ModuleType from unittest.async_case import * from unittest.case import * from unittest.loader import * -from unittest.result import * +from unittest.result import TestResult as TestResult from unittest.runner import * from unittest.signals import * from unittest.suite import * diff --git a/python/helpers/typeshed/stdlib/3/unittest/result.pyi b/python/helpers/typeshed/stdlib/3/unittest/result.pyi index 337b93b7dacc..8fcbc472f009 100644 --- a/python/helpers/typeshed/stdlib/3/unittest/result.pyi +++ b/python/helpers/typeshed/stdlib/3/unittest/result.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional, Tuple, Type, Union +from typing import Any, Callable, List, Optional, Tuple, Type, TypeVar, Union from types import TracebackType import unittest.case @@ -8,6 +8,11 @@ _SysExcInfoType = Union[ Tuple[None, None, None], ] +_F = TypeVar("_F", bound=Callable[..., Any]) + +# undocumented +def failfast(method: _F) -> _F: ... + class TestResult: errors: List[Tuple[unittest.case.TestCase, str]] diff --git a/python/helpers/typeshed/tests/check_consistent.py b/python/helpers/typeshed/tests/check_consistent.py index 12659db04a91..2320e813f9f5 100644 --- a/python/helpers/typeshed/tests/check_consistent.py +++ b/python/helpers/typeshed/tests/check_consistent.py @@ -28,6 +28,7 @@ consistent_files = [ {'stdlib/3.7/contextvars.pyi', 'third_party/3/contextvars.pyi'}, {'stdlib/3/ipaddress.pyi', 'third_party/2/ipaddress.pyi'}, {'stdlib/2/copy_reg.pyi', 'stdlib/3/copyreg.pyi'}, + {'stdlib/2and3/threading.pyi', 'stdlib/2and3/_dummy_threading.pyi'} ] def main(): diff --git a/python/helpers/typeshed/third_party/2/six/__init__.pyi b/python/helpers/typeshed/third_party/2/six/__init__.pyi index 3bed0500ca39..72596a8d7c4b 100644 --- a/python/helpers/typeshed/third_party/2/six/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/six/__init__.pyi @@ -21,6 +21,8 @@ _T = TypeVar('_T') _K = TypeVar('_K') _V = TypeVar('_V') +__version__: str + # TODO make constant, then move this stub to 2and3 # https://github.com/python/typeshed/issues/17 PY2 = True @@ -35,9 +37,6 @@ binary_type = str MAXSIZE: int -# def add_move -# def remove_move - def advance_iterator(it: typing.Iterator[_T]) -> _T: ... next = advance_iterator @@ -94,3 +93,21 @@ def ensure_binary(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) def ensure_str(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> str: ... def ensure_text(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> Text: ... def python_2_unicode_compatible(klass: _T) -> _T: ... + +class _LazyDescriptor: + name: str + def __init__(self, name: str) -> None: ... + def __get__(self, obj: Optional[object], type: Optional[type] = ...) -> Any: ... + +class MovedModule(_LazyDescriptor): + mod: str + def __init__(self, name: str, old: str, new: Optional[str] = ...) -> None: ... + def __getattr__(self, attr: str) -> Any: ... + +class MovedAttribute(_LazyDescriptor): + mod: str + attr: str + def __init__(self, name: str, old_mod: str, new_mod: str, old_attr: Optional[str] = ..., new_attr: Optional[str] = ...) -> None: ... + +def add_move(move: Union[MovedModule, MovedAttribute]) -> None: ... +def remove_move(name: str) -> None: ... diff --git a/python/helpers/typeshed/third_party/2and3/werkzeug/wrappers.pyi b/python/helpers/typeshed/third_party/2and3/werkzeug/wrappers.pyi index c1635b9fcdcb..45a2f009b60a 100644 --- a/python/helpers/typeshed/third_party/2and3/werkzeug/wrappers.pyi +++ b/python/helpers/typeshed/third_party/2and3/werkzeug/wrappers.pyi @@ -132,7 +132,7 @@ class BaseResponse: def make_sequence(self) -> None: ... def iter_encoded(self) -> Iterator[bytes]: ... def set_cookie(self, key, value: str = ..., max_age: Optional[Any] = ..., expires: Optional[Any] = ..., - path: str = ..., domain: Optional[Any] = ..., secure: bool = ..., httponly: bool = ...): ... + path: str = ..., domain: Optional[Any] = ..., secure: bool = ..., httponly: bool = ..., samesite: Optional[str] = ...): ... def delete_cookie(self, key, path: str = ..., domain: Optional[Any] = ...): ... @property def is_streamed(self) -> bool: ... diff --git a/python/helpers/typeshed/third_party/3/six/__init__.pyi b/python/helpers/typeshed/third_party/3/six/__init__.pyi index b785eaca7684..021922522048 100644 --- a/python/helpers/typeshed/third_party/3/six/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/six/__init__.pyi @@ -36,6 +36,8 @@ _T = TypeVar('_T') _K = TypeVar('_K') _V = TypeVar('_V') +__version__: str + # TODO make constant, then move this stub to 2and3 # https://github.com/python/typeshed/issues/17 PY2 = False @@ -50,9 +52,6 @@ binary_type = bytes MAXSIZE: int -# def add_move -# def remove_move - def callable(obj: object) -> bool: ... def get_unbound_function(unbound: types.FunctionType) -> types.FunctionType: ... @@ -106,3 +105,21 @@ def ensure_binary(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) def ensure_str(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> str: ... def ensure_text(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> Text: ... def python_2_unicode_compatible(klass: _T) -> _T: ... + +class _LazyDescriptor: + name: str + def __init__(self, name: str) -> None: ... + def __get__(self, obj: Optional[object], type: Optional[type] = ...) -> Any: ... + +class MovedModule(_LazyDescriptor): + mod: str + def __init__(self, name: str, old: str, new: Optional[str] = ...) -> None: ... + def __getattr__(self, attr: str) -> Any: ... + +class MovedAttribute(_LazyDescriptor): + mod: str + attr: str + def __init__(self, name: str, old_mod: str, new_mod: str, old_attr: Optional[str] = ..., new_attr: Optional[str] = ...) -> None: ... + +def add_move(move: Union[MovedModule, MovedAttribute]) -> None: ... +def remove_move(name: str) -> None: ... diff --git a/python/testData/inspections/PyArgumentListInspection/dictFromKeys.py b/python/testData/inspections/PyArgumentListInspection/dictFromKeys.py index c9989e1f8b63..e5a56d774f09 100644 --- a/python/testData/inspections/PyArgumentListInspection/dictFromKeys.py +++ b/python/testData/inspections/PyArgumentListInspection/dictFromKeys.py @@ -1,2 +1,2 @@ -print(dict.fromkeys()) +print(dict.fromkeys()) print(dict.fromkeys(['foo', 'bar'])) diff --git a/python/testData/inspections/PyArgumentListInspection/typedDictMethods.py b/python/testData/inspections/PyArgumentListInspection/typedDictMethods.py index b2d2019d74d1..379ba24bd40e 100644 --- a/python/testData/inspections/PyArgumentListInspection/typedDictMethods.py +++ b/python/testData/inspections/PyArgumentListInspection/typedDictMethods.py @@ -7,10 +7,10 @@ class X(TypedDict): x = X(x=42) x.clear() -x.setdefault() +x.setdefault() x.setdefault('x', 43) x1: X = {'x': 42} x1.clear() -x1.setdefault() +x1.setdefault() x1.setdefault('x', 43) diff --git a/python/testData/quickdoc/BuiltinLen.html b/python/testData/quickdoc/BuiltinLen.html index 232ff55d5d70..ba649800b333 100644 --- a/python/testData/quickdoc/BuiltinLen.html +++ b/python/testData/quickdoc/BuiltinLen.html @@ -1 +1 @@ -
__builtin__
def len(__o: Sized) -> int
len(object) -> integer

Return the number of items of a sequence or collection.
\ No newline at end of file +
__builtin__
def len(__obj: Sized) -> int
len(object) -> integer

Return the number of items of a sequence or collection.
\ No newline at end of file diff --git a/python/testData/quickdoc/ReferenceToMethodQualifiedWithInstance.html b/python/testData/quickdoc/ReferenceToMethodQualifiedWithInstance.html index bdd28c80ece2..01c2f2945593 100644 --- a/python/testData/quickdoc/ReferenceToMethodQualifiedWithInstance.html +++ b/python/testData/quickdoc/ReferenceToMethodQualifiedWithInstance.html @@ -1 +1 @@ -
list
def count(self, object: _T) -> int
L.count(value) -> integer -- return number of occurrences of value

Assigned to:

c1
\ No newline at end of file +
list
def count(self, __value: _T) -> int
L.count(value) -> integer -- return number of occurrences of value

Assigned to:

c1
\ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 78e7d4420670..87eb5f08bc0d 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -2315,14 +2315,14 @@ public class PyTypeTest extends PyTestCase { // PY-24323 public void testMethodQualifiedWithUnknownGenericsInstance() { - doTest("(object: Any) -> int", + doTest("(__value: Any) -> int", "my_list = []\n" + "expr = my_list.count"); } // PY-24323 public void testMethodQualifiedWithKnownGenericsInstance() { - doTest("(object: int) -> int", + doTest("(__value: int) -> int", "my_list = [1, 2, 2, 3, 3]\n" + "expr = my_list.count"); } diff --git a/python/tools/src/com/jetbrains/python/tools/PyTypeShedSync.kts b/python/tools/src/com/jetbrains/python/tools/PyTypeShedSync.kts index 7df4d7fe8675..0d39e35469d2 100644 --- a/python/tools/src/com/jetbrains/python/tools/PyTypeShedSync.kts +++ b/python/tools/src/com/jetbrains/python/tools/PyTypeShedSync.kts @@ -102,9 +102,9 @@ fun sync(repo: Path, bundled: Path) { ".gitignore", ".travis.yml", "CONTRIBUTING.md", - "README.md", "LICENSE", - "requirements-tests-py2.txt", + "pyproject.toml", + "README.md", "requirements-tests-py3.txt") Files