Use PEP 585 syntax in @python2/_ast, convert more TypeVars to _typeshed.Self, & # noqa a SQLAlchemy line (#6954)

* Manual fixes for `_ast` and `SQLAlchemy`

* Change more `TypeVar`s to `Self`, using script
This commit is contained in:
Alex Waygood
2022-01-18 19:15:34 +00:00
committed by GitHub
parent 989fe11806
commit cd93461225
9 changed files with 105 additions and 102 deletions

View File

@@ -82,13 +82,13 @@ class object:
class staticmethod(object): # Special, only valid as a decorator.
__func__: Callable[..., Any]
def __init__(self, f: Callable[..., Any]) -> None: ...
def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ...
def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ...
class classmethod(object): # Special, only valid as a decorator.
__func__: Callable[..., Any]
def __init__(self, f: Callable[..., Any]) -> None: ...
def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ...
def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ...
class type(object):
@@ -127,9 +127,9 @@ class super(object):
class int:
@overload
def __new__(cls: type[_T], x: Text | bytes | SupportsInt | _SupportsIndex | _SupportsTrunc = ...) -> _T: ...
def __new__(cls: type[Self], x: Text | bytes | SupportsInt | _SupportsIndex | _SupportsTrunc = ...) -> Self: ...
@overload
def __new__(cls: type[_T], x: Text | bytes | bytearray, base: int) -> _T: ...
def __new__(cls: type[Self], x: Text | bytes | bytearray, base: int) -> Self: ...
@property
def real(self) -> int: ...
@property
@@ -191,7 +191,7 @@ class int:
def __index__(self) -> int: ...
class float:
def __new__(cls: type[_T], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> _T: ...
def __new__(cls: type[Self], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> Self: ...
def as_integer_ratio(self) -> tuple[int, int]: ...
def hex(self) -> str: ...
def is_integer(self) -> bool: ...
@@ -241,9 +241,9 @@ class float:
class complex:
@overload
def __new__(cls: type[_T], real: float = ..., imag: float = ...) -> _T: ...
def __new__(cls: type[Self], real: float = ..., imag: float = ...) -> Self: ...
@overload
def __new__(cls: type[_T], real: str | SupportsComplex | _SupportsIndex) -> _T: ...
def __new__(cls: type[Self], real: str | SupportsComplex | _SupportsIndex) -> Self: ...
@property
def real(self) -> float: ...
@property
@@ -548,7 +548,7 @@ class memoryview(Sized, Container[str]):
@final
class bool(int):
def __new__(cls: type[_T], __o: object = ...) -> _T: ...
def __new__(cls: type[Self], __o: object = ...) -> Self: ...
@overload
def __and__(self, x: bool) -> bool: ...
@overload
@@ -587,7 +587,7 @@ class slice(object):
def indices(self, len: int) -> tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
def __new__(cls: type[_T], iterable: Iterable[_T_co] = ...) -> _T: ...
def __new__(cls: type[Self], iterable: Iterable[_T_co] = ...) -> Self: ...
def __len__(self) -> int: ...
def __contains__(self, x: object) -> bool: ...
@overload
@@ -664,7 +664,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ...
@overload
def __init__(self, iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def __new__(cls: type[_T1], *args: Any, **kwargs: Any) -> _T1: ...
def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ...
def has_key(self, k: _KT) -> bool: ...
def clear(self) -> None: ...
def copy(self) -> dict[_KT, _VT]: ...