From 6f159d9fc6a449c2182edba24971e81c253fca05 Mon Sep 17 00:00:00 2001 From: Jan Verbeek <55185397+janverb@users.noreply.github.com> Date: Sat, 14 Mar 2020 04:48:42 +0100 Subject: [PATCH] Make Python 2's inspect more tolerant of unicode (#3847) --- stdlib/2/inspect.pyi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/2/inspect.pyi b/stdlib/2/inspect.pyi index c5ed0ca7f..6f6fea49c 100644 --- a/stdlib/2/inspect.pyi +++ b/stdlib/2/inspect.pyi @@ -1,5 +1,5 @@ from types import CodeType, TracebackType, FrameType, FunctionType, MethodType, ModuleType -from typing import Any, Dict, Callable, List, NamedTuple, Optional, Sequence, Tuple, Type, Union +from typing import Any, Dict, Callable, List, NamedTuple, Optional, Sequence, Tuple, Type, Union, AnyStr # Types and members class EndOfBlock(Exception): ... @@ -10,8 +10,8 @@ class BlockFinder: started: bool passline: bool last: int - def tokeneater(self, type: int, token: str, srow_scol: Tuple[int, int], - erow_ecol: Tuple[int, int], line: str) -> None: ... + def tokeneater(self, type: int, token: AnyStr, srow_scol: Tuple[int, int], + erow_ecol: Tuple[int, int], line: AnyStr) -> None: ... CO_GENERATOR: int CO_NESTED: int @@ -32,8 +32,8 @@ def getmembers( object: object, predicate: Optional[Callable[[Any], bool]] = ... ) -> List[Tuple[str, Any]]: ... -def getmoduleinfo(path: str) -> Optional[ModuleInfo]: ... -def getmodulename(path: str) -> Optional[str]: ... +def getmoduleinfo(path: Union[str, unicode]) -> Optional[ModuleInfo]: ... +def getmodulename(path: AnyStr) -> Optional[AnyStr]: ... def ismodule(object: object) -> bool: ... def isclass(object: object) -> bool: ... @@ -57,7 +57,7 @@ _SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, Trace def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ... def getabsfile(object: _SourceObjectType) -> str: ... -def getblock(lines: Sequence[str]) -> Sequence[str]: ... +def getblock(lines: Sequence[AnyStr]) -> Sequence[AnyStr]: ... def getdoc(object: object) -> Optional[str]: ... def getcomments(object: object) -> Optional[str]: ... def getfile(object: _SourceObjectType) -> str: ... @@ -65,8 +65,8 @@ def getmodule(object: object) -> Optional[ModuleType]: ... def getsourcefile(object: _SourceObjectType) -> Optional[str]: ... def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ... def getsource(object: _SourceObjectType) -> str: ... -def cleandoc(doc: str) -> str: ... -def indentsize(line: str) -> int: ... +def cleandoc(doc: AnyStr) -> AnyStr: ... +def indentsize(line: Union[str, unicode]) -> int: ... # Classes and functions def getclasstree(classes: List[type], unique: bool = ...) -> List[Union[Tuple[type, Tuple[type, ...]], List[Any]]]: ...