diff --git a/stubs/six/@python2/six/__init__.pyi b/stubs/six/@python2/six/__init__.pyi index f6d6af1e0..5c448102b 100644 --- a/stubs/six/@python2/six/__init__.pyi +++ b/stubs/six/@python2/six/__init__.pyi @@ -10,22 +10,20 @@ from typing import ( Any, AnyStr, Callable, - Dict, ItemsView, Iterable, KeysView, Mapping, NoReturn, - Optional, Pattern, Text, Tuple, Type, TypeVar, - Union, ValuesView, overload, ) +from typing_extensions import Literal from . import moves @@ -35,19 +33,18 @@ _T = TypeVar("_T") _K = TypeVar("_K") _V = TypeVar("_V") +__author__: str __version__: str -# TODO make constant, then move this stub to 2and3 -# https://github.com/python/typeshed/issues/17 -PY2 = True -PY3 = False -PY34 = False +PY2: Literal[True] +PY3: Literal[False] +PY34: Literal[False] -string_types = (str, unicode) -integer_types = (int, long) -class_types = (type, types.ClassType) -text_type = unicode -binary_type = str +string_types: tuple[Type[str], Type[unicode]] +integer_types: tuple[Type[int], Type[long]] +class_types: tuple[Type[Type[Any]], Type[types.ClassType]] +text_type: Type[unicode] +binary_type: Type[str] MAXSIZE: int @@ -58,73 +55,67 @@ next = advance_iterator def callable(obj: object) -> bool: ... def get_unbound_function(unbound: types.MethodType) -> types.FunctionType: ... def create_bound_method(func: types.FunctionType, obj: object) -> types.MethodType: ... -def create_unbound_method(func: types.FunctionType, cls: Union[type, types.ClassType]) -> types.MethodType: ... +def create_unbound_method(func: types.FunctionType, cls: type | types.ClassType) -> types.MethodType: ... class Iterator: def next(self) -> Any: ... def get_method_function(meth: types.MethodType) -> types.FunctionType: ... -def get_method_self(meth: types.MethodType) -> Optional[object]: ... -def get_function_closure(fun: types.FunctionType) -> Optional[Tuple[types._Cell, ...]]: ... +def get_method_self(meth: types.MethodType) -> object | None: ... +def get_function_closure(fun: types.FunctionType) -> Tuple[types._Cell, ...] | None: ... def get_function_code(fun: types.FunctionType) -> types.CodeType: ... -def get_function_defaults(fun: types.FunctionType) -> Optional[Tuple[Any, ...]]: ... -def get_function_globals(fun: types.FunctionType) -> Dict[str, Any]: ... +def get_function_defaults(fun: types.FunctionType) -> Tuple[Any, ...] | None: ... +def get_function_globals(fun: types.FunctionType) -> dict[str, Any]: ... def iterkeys(d: Mapping[_K, _V]) -> typing.Iterator[_K]: ... def itervalues(d: Mapping[_K, _V]) -> typing.Iterator[_V]: ... -def iteritems(d: Mapping[_K, _V]) -> typing.Iterator[Tuple[_K, _V]]: ... +def iteritems(d: Mapping[_K, _V]) -> typing.Iterator[tuple[_K, _V]]: ... # def iterlists def viewkeys(d: Mapping[_K, _V]) -> KeysView[_K]: ... def viewvalues(d: Mapping[_K, _V]) -> ValuesView[_V]: ... def viewitems(d: Mapping[_K, _V]) -> ItemsView[_K, _V]: ... -def b(s: str) -> binary_type: ... -def u(s: str) -> text_type: ... +def b(s: str) -> str: ... +def u(s: str) -> unicode: ... int2byte = chr -def byte2int(bs: binary_type) -> int: ... -def indexbytes(buf: binary_type, i: int) -> int: ... -def iterbytes(buf: binary_type) -> typing.Iterator[int]: ... +def byte2int(bs: str) -> int: ... +def indexbytes(buf: str, i: int) -> int: ... +def iterbytes(buf: str) -> typing.Iterator[int]: ... def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: str = ...) -> None: ... @overload def assertRaisesRegex(self: unittest.TestCase, msg: str = ...) -> Any: ... @overload def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ... -def assertRegex( - self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: str = ... -) -> None: ... -def reraise( - tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ... -) -> NoReturn: ... -def exec_(_code_: Union[unicode, types.CodeType], _globs_: Dict[str, Any] = ..., _locs_: Dict[str, Any] = ...): ... -def raise_from(value: Union[BaseException, Type[BaseException]], from_value: Optional[BaseException]) -> NoReturn: ... +def assertRegex(self: unittest.TestCase, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: str = ...) -> None: ... +def reraise(tp: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ... +def exec_(_code_: unicode | types.CodeType, _globs_: dict[str, Any] = ..., _locs_: dict[str, Any] = ...): ... +def raise_from(value: BaseException | Type[BaseException], from_value: BaseException | None) -> NoReturn: ... print_ = print def with_metaclass(meta: type, *bases: type) -> type: ... def add_metaclass(metaclass: type) -> Callable[[_T], _T]: ... -def ensure_binary(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> bytes: ... -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 ensure_binary(s: bytes | Text, encoding: str = ..., errors: str = ...) -> bytes: ... +def ensure_str(s: bytes | Text, encoding: str = ..., errors: str = ...) -> str: ... +def ensure_text(s: bytes | Text, encoding: str = ..., errors: str = ...) -> Text: ... def python_2_unicode_compatible(klass: _T) -> _T: ... -class _LazyDescriptor: +class _LazyDescr(object): name: str def __init__(self, name: str) -> None: ... - def __get__(self, obj: Optional[object], type: Optional[type] = ...) -> Any: ... + def __get__(self, obj: object | None, type: Type[Any] | None = ...) -> Any: ... -class MovedModule(_LazyDescriptor): +class MovedModule(_LazyDescr): mod: str - def __init__(self, name: str, old: str, new: Optional[str] = ...) -> None: ... + def __init__(self, name: str, old: str, new: str | None = ...) -> None: ... def __getattr__(self, attr: str) -> Any: ... -class MovedAttribute(_LazyDescriptor): +class MovedAttribute(_LazyDescr): 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 __init__(self, name: str, old_mod: str, new_mod: str, old_attr: str | None = ..., new_attr: str | None = ...) -> None: ... -def add_move(move: Union[MovedModule, MovedAttribute]) -> None: ... +def add_move(move: MovedModule | MovedAttribute) -> None: ... def remove_move(name: str) -> None: ... diff --git a/stubs/six/METADATA.toml b/stubs/six/METADATA.toml index 31f638bf3..ff19b6193 100644 --- a/stubs/six/METADATA.toml +++ b/stubs/six/METADATA.toml @@ -1,2 +1,2 @@ -version = "0.1" +version = "1.16" python2 = true diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 46e922bcb..939e8d3c8 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -1,27 +1,13 @@ from __future__ import print_function import types -import typing import unittest from builtins import next as next +from collections.abc import Callable, ItemsView, Iterable, Iterator as _Iterator, KeysView, Mapping, ValuesView from functools import wraps as wraps from io import BytesIO as BytesIO, StringIO as StringIO -from typing import ( - Any, - AnyStr, - Callable, - ItemsView, - Iterable, - KeysView, - Mapping, - NoReturn, - Pattern, - Tuple, - Type, - TypeVar, - ValuesView, - overload, -) +from typing import Any, AnyStr, NoReturn, Pattern, Tuple, Type, TypeVar, overload +from typing_extensions import Literal from . import moves as moves @@ -29,19 +15,18 @@ _T = TypeVar("_T") _K = TypeVar("_K") _V = TypeVar("_V") +__author__: str __version__: str -# TODO make constant, then move this stub to 2and3 -# https://github.com/python/typeshed/issues/17 -PY2 = False -PY3 = True -PY34: bool +PY2: Literal[False] +PY3: Literal[True] +PY34: Literal[True] -string_types = (str,) -integer_types = (int,) -class_types = (type,) -text_type = str -binary_type = bytes +string_types: tuple[Type[str]] +integer_types: tuple[Type[int]] +class_types: tuple[Type[Type[Any]]] +text_type: Type[str] +binary_type: Type[bytes] MAXSIZE: int @@ -58,24 +43,24 @@ def get_function_closure(fun: types.FunctionType) -> Tuple[types._Cell, ...] | N def get_function_code(fun: types.FunctionType) -> types.CodeType: ... def get_function_defaults(fun: types.FunctionType) -> Tuple[Any, ...] | None: ... def get_function_globals(fun: types.FunctionType) -> dict[str, Any]: ... -def iterkeys(d: Mapping[_K, Any]) -> typing.Iterator[_K]: ... -def itervalues(d: Mapping[Any, _V]) -> typing.Iterator[_V]: ... -def iteritems(d: Mapping[_K, _V]) -> typing.Iterator[Tuple[_K, _V]]: ... +def iterkeys(d: Mapping[_K, Any]) -> _Iterator[_K]: ... +def itervalues(d: Mapping[Any, _V]) -> _Iterator[_V]: ... +def iteritems(d: Mapping[_K, _V]) -> _Iterator[tuple[_K, _V]]: ... # def iterlists def viewkeys(d: Mapping[_K, Any]) -> KeysView[_K]: ... def viewvalues(d: Mapping[Any, _V]) -> ValuesView[_V]: ... def viewitems(d: Mapping[_K, _V]) -> ItemsView[_K, _V]: ... -def b(s: str) -> binary_type: ... -def u(s: str) -> text_type: ... +def b(s: str) -> bytes: ... +def u(s: str) -> str: ... unichr = chr def int2byte(i: int) -> bytes: ... -def byte2int(bs: binary_type) -> int: ... -def indexbytes(buf: binary_type, i: int) -> int: ... -def iterbytes(buf: binary_type) -> typing.Iterator[int]: ... +def byte2int(bs: bytes) -> int: ... +def indexbytes(buf: bytes, i: int) -> int: ... +def iterbytes(buf: bytes) -> _Iterator[int]: ... def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: str | None = ...) -> None: ... @overload def assertRaisesRegex(self: unittest.TestCase, msg: str | None = ...) -> Any: ... @@ -99,17 +84,17 @@ def ensure_str(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: . def ensure_text(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: ... def python_2_unicode_compatible(klass: _T) -> _T: ... -class _LazyDescriptor: +class _LazyDescr: name: str def __init__(self, name: str) -> None: ... - def __get__(self, obj: object | None, type: type | None = ...) -> Any: ... + def __get__(self, obj: object | None, type: Type[Any] | None = ...) -> Any: ... -class MovedModule(_LazyDescriptor): +class MovedModule(_LazyDescr): mod: str def __init__(self, name: str, old: str, new: str | None = ...) -> None: ... def __getattr__(self, attr: str) -> Any: ... -class MovedAttribute(_LazyDescriptor): +class MovedAttribute(_LazyDescr): mod: str attr: str def __init__(self, name: str, old_mod: str, new_mod: str, old_attr: str | None = ..., new_attr: str | None = ...) -> None: ...