mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from types import CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType
|
||||
from typing import Any, AnyStr, Callable, Dict, List, NamedTuple, Optional, Sequence, Tuple, Type, Union
|
||||
from typing import Any, AnyStr, Callable, NamedTuple, Optional, Sequence, Union
|
||||
|
||||
# Types and members
|
||||
class EndOfBlock(Exception): ...
|
||||
@@ -11,7 +11,7 @@ class BlockFinder:
|
||||
passline: bool
|
||||
last: int
|
||||
def tokeneater(
|
||||
self, type: int, token: AnyStr, srow_scol: Tuple[int, int], erow_ecol: Tuple[int, int], line: AnyStr
|
||||
self, type: int, token: AnyStr, srow_scol: tuple[int, int], erow_ecol: tuple[int, int], line: AnyStr
|
||||
) -> None: ...
|
||||
|
||||
CO_GENERATOR: int
|
||||
@@ -29,7 +29,7 @@ class ModuleInfo(NamedTuple):
|
||||
mode: str
|
||||
module_type: int
|
||||
|
||||
def getmembers(object: object, predicate: Callable[[Any], bool] | None = ...) -> List[Tuple[str, Any]]: ...
|
||||
def getmembers(object: object, predicate: Callable[[Any], bool] | None = ...) -> list[tuple[str, Any]]: ...
|
||||
def getmoduleinfo(path: str | unicode) -> ModuleInfo | None: ...
|
||||
def getmodulename(path: AnyStr) -> AnyStr | None: ...
|
||||
def ismodule(object: object) -> bool: ...
|
||||
@@ -50,9 +50,9 @@ def isgetsetdescriptor(object: object) -> bool: ...
|
||||
def ismemberdescriptor(object: object) -> bool: ...
|
||||
|
||||
# Retrieving source code
|
||||
_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]]
|
||||
_SourceObjectType = Union[ModuleType, type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]]
|
||||
|
||||
def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ...
|
||||
def findsource(object: _SourceObjectType) -> tuple[list[str], int]: ...
|
||||
def getabsfile(object: _SourceObjectType) -> str: ...
|
||||
def getblock(lines: Sequence[AnyStr]) -> Sequence[AnyStr]: ...
|
||||
def getdoc(object: object) -> str | None: ...
|
||||
@@ -60,28 +60,28 @@ def getcomments(object: object) -> str | None: ...
|
||||
def getfile(object: _SourceObjectType) -> str: ...
|
||||
def getmodule(object: object) -> ModuleType | None: ...
|
||||
def getsourcefile(object: _SourceObjectType) -> str | None: ...
|
||||
def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ...
|
||||
def getsourcelines(object: _SourceObjectType) -> tuple[list[str], int]: ...
|
||||
def getsource(object: _SourceObjectType) -> str: ...
|
||||
def cleandoc(doc: AnyStr) -> AnyStr: ...
|
||||
def indentsize(line: str | unicode) -> int: ...
|
||||
|
||||
# Classes and functions
|
||||
def getclasstree(classes: List[type], unique: bool = ...) -> List[Tuple[type, Tuple[type, ...]] | List[Any]]: ...
|
||||
def getclasstree(classes: list[type], unique: bool = ...) -> list[tuple[type, tuple[type, ...]] | list[Any]]: ...
|
||||
|
||||
class ArgSpec(NamedTuple):
|
||||
args: List[str]
|
||||
args: list[str]
|
||||
varargs: str | None
|
||||
keywords: str | None
|
||||
defaults: Tuple[Any, ...]
|
||||
defaults: tuple[Any, ...]
|
||||
|
||||
class ArgInfo(NamedTuple):
|
||||
args: List[str]
|
||||
args: list[str]
|
||||
varargs: str | None
|
||||
keywords: str | None
|
||||
locals: Dict[str, Any]
|
||||
locals: dict[str, Any]
|
||||
|
||||
class Arguments(NamedTuple):
|
||||
args: List[str | List[Any]]
|
||||
args: list[str | list[Any]]
|
||||
varargs: str | None
|
||||
keywords: str | None
|
||||
|
||||
@@ -94,8 +94,8 @@ def formatargspec(
|
||||
def formatargvalues(
|
||||
args, varargs=..., varkw=..., defaults=..., formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=..., join=...
|
||||
) -> str: ...
|
||||
def getmro(cls: type) -> Tuple[type, ...]: ...
|
||||
def getcallargs(func, *args, **kwds) -> Dict[str, Any]: ...
|
||||
def getmro(cls: type) -> tuple[type, ...]: ...
|
||||
def getcallargs(func, *args, **kwds) -> dict[str, Any]: ...
|
||||
|
||||
# The interpreter stack
|
||||
|
||||
@@ -103,18 +103,18 @@ class Traceback(NamedTuple):
|
||||
filename: str
|
||||
lineno: int
|
||||
function: str
|
||||
code_context: List[str] | None
|
||||
code_context: list[str] | None
|
||||
index: int | None # type: ignore
|
||||
|
||||
_FrameInfo = Tuple[FrameType, str, int, str, Optional[List[str]], Optional[int]]
|
||||
_FrameInfo = tuple[FrameType, str, int, str, Optional[list[str]], Optional[int]]
|
||||
|
||||
def getouterframes(frame: FrameType, context: int = ...) -> List[_FrameInfo]: ...
|
||||
def getouterframes(frame: FrameType, context: int = ...) -> list[_FrameInfo]: ...
|
||||
def getframeinfo(frame: FrameType | TracebackType, context: int = ...) -> Traceback: ...
|
||||
def getinnerframes(traceback: TracebackType, context: int = ...) -> List[_FrameInfo]: ...
|
||||
def getinnerframes(traceback: TracebackType, context: int = ...) -> list[_FrameInfo]: ...
|
||||
def getlineno(frame: FrameType) -> int: ...
|
||||
def currentframe(depth: int = ...) -> FrameType: ...
|
||||
def stack(context: int = ...) -> List[_FrameInfo]: ...
|
||||
def trace(context: int = ...) -> List[_FrameInfo]: ...
|
||||
def stack(context: int = ...) -> list[_FrameInfo]: ...
|
||||
def trace(context: int = ...) -> list[_FrameInfo]: ...
|
||||
|
||||
# Create private type alias to avoid conflict with symbol of same
|
||||
# name created in Attribute class.
|
||||
@@ -126,4 +126,4 @@ class Attribute(NamedTuple):
|
||||
defining_class: type
|
||||
object: _Object
|
||||
|
||||
def classify_class_attrs(cls: type) -> List[Attribute]: ...
|
||||
def classify_class_attrs(cls: type) -> list[Attribute]: ...
|
||||
|
||||
Reference in New Issue
Block a user