Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions stdlib/@python2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]: ...
Expand Down
96 changes: 47 additions & 49 deletions stdlib/@python2/_ast.pyi
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import typing

__version__: str
PyCF_ONLY_AST: int
_identifier = str

class AST:
_attributes: typing.Tuple[str, ...]
_fields: typing.Tuple[str, ...]
_attributes: tuple[str, ...]
_fields: tuple[str, ...]
def __init__(self, *args, **kwargs) -> None: ...

class mod(AST): ...

class Module(mod):
body: typing.List[stmt]
body: list[stmt]

class Interactive(mod):
body: typing.List[stmt]
body: list[stmt]

class Expression(mod):
body: expr

class Suite(mod):
body: typing.List[stmt]
body: list[stmt]

class stmt(AST):
lineno: int
Expand All @@ -30,23 +28,23 @@ class stmt(AST):
class FunctionDef(stmt):
name: _identifier
args: arguments
body: typing.List[stmt]
decorator_list: typing.List[expr]
body: list[stmt]
decorator_list: list[expr]

class ClassDef(stmt):
name: _identifier
bases: typing.List[expr]
body: typing.List[stmt]
decorator_list: typing.List[expr]
bases: list[expr]
body: list[stmt]
decorator_list: list[expr]

class Return(stmt):
value: expr | None

class Delete(stmt):
targets: typing.List[expr]
targets: list[expr]

class Assign(stmt):
targets: typing.List[expr]
targets: list[expr]
value: expr

class AugAssign(stmt):
Expand All @@ -56,54 +54,54 @@ class AugAssign(stmt):

class Print(stmt):
dest: expr | None
values: typing.List[expr]
values: list[expr]
nl: bool

class For(stmt):
target: expr
iter: expr
body: typing.List[stmt]
orelse: typing.List[stmt]
body: list[stmt]
orelse: list[stmt]

class While(stmt):
test: expr
body: typing.List[stmt]
orelse: typing.List[stmt]
body: list[stmt]
orelse: list[stmt]

class If(stmt):
test: expr
body: typing.List[stmt]
orelse: typing.List[stmt]
body: list[stmt]
orelse: list[stmt]

class With(stmt):
context_expr: expr
optional_vars: expr | None
body: typing.List[stmt]
body: list[stmt]

class Raise(stmt):
type: expr | None
inst: expr | None
tback: expr | None

class TryExcept(stmt):
body: typing.List[stmt]
handlers: typing.List[ExceptHandler]
orelse: typing.List[stmt]
body: list[stmt]
handlers: list[ExceptHandler]
orelse: list[stmt]

class TryFinally(stmt):
body: typing.List[stmt]
finalbody: typing.List[stmt]
body: list[stmt]
finalbody: list[stmt]

class Assert(stmt):
test: expr
msg: expr | None

class Import(stmt):
names: typing.List[alias]
names: list[alias]

class ImportFrom(stmt):
module: _identifier | None
names: typing.List[alias]
names: list[alias]
level: int | None

class Exec(stmt):
Expand All @@ -112,7 +110,7 @@ class Exec(stmt):
locals: expr | None

class Global(stmt):
names: typing.List[_identifier]
names: list[_identifier]

class Expr(stmt):
value: expr
Expand All @@ -130,7 +128,7 @@ class Slice(slice):
step: expr | None

class ExtSlice(slice):
dims: typing.List[slice]
dims: list[slice]

class Index(slice):
value: expr
Expand All @@ -143,7 +141,7 @@ class expr(AST):

class BoolOp(expr):
op: boolop
values: typing.List[expr]
values: list[expr]

class BinOp(expr):
left: expr
Expand All @@ -164,41 +162,41 @@ class IfExp(expr):
orelse: expr

class Dict(expr):
keys: typing.List[expr]
values: typing.List[expr]
keys: list[expr]
values: list[expr]

class Set(expr):
elts: typing.List[expr]
elts: list[expr]

class ListComp(expr):
elt: expr
generators: typing.List[comprehension]
generators: list[comprehension]

class SetComp(expr):
elt: expr
generators: typing.List[comprehension]
generators: list[comprehension]

class DictComp(expr):
key: expr
value: expr
generators: typing.List[comprehension]
generators: list[comprehension]

class GeneratorExp(expr):
elt: expr
generators: typing.List[comprehension]
generators: list[comprehension]

class Yield(expr):
value: expr | None

class Compare(expr):
left: expr
ops: typing.List[cmpop]
comparators: typing.List[expr]
ops: list[cmpop]
comparators: list[expr]

class Call(expr):
func: expr
args: typing.List[expr]
keywords: typing.List[keyword]
args: list[expr]
keywords: list[keyword]
starargs: expr | None
kwargs: expr | None

Expand Down Expand Up @@ -226,11 +224,11 @@ class Name(expr):
ctx: expr_context

class List(expr):
elts: typing.List[expr]
elts: list[expr]
ctx: expr_context

class Tuple(expr):
elts: typing.List[expr]
elts: list[expr]
ctx: expr_context

class expr_context(AST): ...
Expand Down Expand Up @@ -276,22 +274,22 @@ class NotIn(cmpop): ...
class comprehension(AST):
target: expr
iter: expr
ifs: typing.List[expr]
ifs: list[expr]

class excepthandler(AST): ...

class ExceptHandler(excepthandler):
type: expr | None
name: expr | None
body: typing.List[stmt]
body: list[stmt]
lineno: int
col_offset: int

class arguments(AST):
args: typing.List[expr]
args: list[expr]
vararg: _identifier | None
kwarg: _identifier | None
defaults: typing.List[expr]
defaults: list[expr]

class keyword(AST):
arg: _identifier
Expand Down
Loading