Skip to content

Commit 6f159d9

Browse files
authored
Make Python 2's inspect more tolerant of unicode (#3847)
1 parent 01d4a4c commit 6f159d9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

stdlib/2/inspect.pyi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from types import CodeType, TracebackType, FrameType, FunctionType, MethodType, ModuleType
2-
from typing import Any, Dict, Callable, List, NamedTuple, Optional, Sequence, Tuple, Type, Union
2+
from typing import Any, Dict, Callable, List, NamedTuple, Optional, Sequence, Tuple, Type, Union, AnyStr
33

44
# Types and members
55
class EndOfBlock(Exception): ...
@@ -10,8 +10,8 @@ class BlockFinder:
1010
started: bool
1111
passline: bool
1212
last: int
13-
def tokeneater(self, type: int, token: str, srow_scol: Tuple[int, int],
14-
erow_ecol: Tuple[int, int], line: str) -> None: ...
13+
def tokeneater(self, type: int, token: AnyStr, srow_scol: Tuple[int, int],
14+
erow_ecol: Tuple[int, int], line: AnyStr) -> None: ...
1515

1616
CO_GENERATOR: int
1717
CO_NESTED: int
@@ -32,8 +32,8 @@ def getmembers(
3232
object: object,
3333
predicate: Optional[Callable[[Any], bool]] = ...
3434
) -> List[Tuple[str, Any]]: ...
35-
def getmoduleinfo(path: str) -> Optional[ModuleInfo]: ...
36-
def getmodulename(path: str) -> Optional[str]: ...
35+
def getmoduleinfo(path: Union[str, unicode]) -> Optional[ModuleInfo]: ...
36+
def getmodulename(path: AnyStr) -> Optional[AnyStr]: ...
3737

3838
def ismodule(object: object) -> bool: ...
3939
def isclass(object: object) -> bool: ...
@@ -57,16 +57,16 @@ _SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, Trace
5757

5858
def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ...
5959
def getabsfile(object: _SourceObjectType) -> str: ...
60-
def getblock(lines: Sequence[str]) -> Sequence[str]: ...
60+
def getblock(lines: Sequence[AnyStr]) -> Sequence[AnyStr]: ...
6161
def getdoc(object: object) -> Optional[str]: ...
6262
def getcomments(object: object) -> Optional[str]: ...
6363
def getfile(object: _SourceObjectType) -> str: ...
6464
def getmodule(object: object) -> Optional[ModuleType]: ...
6565
def getsourcefile(object: _SourceObjectType) -> Optional[str]: ...
6666
def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ...
6767
def getsource(object: _SourceObjectType) -> str: ...
68-
def cleandoc(doc: str) -> str: ...
69-
def indentsize(line: str) -> int: ...
68+
def cleandoc(doc: AnyStr) -> AnyStr: ...
69+
def indentsize(line: Union[str, unicode]) -> int: ...
7070

7171
# Classes and functions
7272
def getclasstree(classes: List[type], unique: bool = ...) -> List[Union[Tuple[type, Tuple[type, ...]], List[Any]]]: ...

0 commit comments

Comments
 (0)