Skip to content

Commit 4d3cc1f

Browse files
authored
dis: fix types (#9025)
`_get_code_object` cannot take bytes
1 parent 921ddae commit 4d3cc1f

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

stdlib/dis.pyi

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ __all__ = [
3737
# Strictly this should not have to include Callable, but mypy doesn't use FunctionType
3838
# for functions (python/mypy#3171)
3939
_HaveCodeType: TypeAlias = types.MethodType | types.FunctionType | types.CodeType | type | Callable[..., Any]
40-
_HaveCodeOrStringType: TypeAlias = _HaveCodeType | str | bytes
4140

4241
if sys.version_info >= (3, 11):
4342
class Positions(NamedTuple):
@@ -75,7 +74,7 @@ class Bytecode:
7574
if sys.version_info >= (3, 11):
7675
def __init__(
7776
self,
78-
x: _HaveCodeOrStringType,
77+
x: _HaveCodeType | str,
7978
*,
8079
first_line: int | None = ...,
8180
current_offset: int | None = ...,
@@ -87,9 +86,7 @@ class Bytecode:
8786
cls: type[Self], tb: types.TracebackType, *, show_caches: bool = ..., adaptive: bool = ...
8887
) -> Self: ...
8988
else:
90-
def __init__(
91-
self, x: _HaveCodeOrStringType, *, first_line: int | None = ..., current_offset: int | None = ...
92-
) -> None: ...
89+
def __init__(self, x: _HaveCodeType | str, *, first_line: int | None = ..., current_offset: int | None = ...) -> None: ...
9390
@classmethod
9491
def from_traceback(cls: type[Self], tb: types.TracebackType) -> Self: ...
9592

@@ -102,11 +99,11 @@ COMPILER_FLAG_NAMES: dict[int, str]
10299
def findlabels(code: _HaveCodeType) -> list[int]: ...
103100
def findlinestarts(code: _HaveCodeType) -> Iterator[tuple[int, int]]: ...
104101
def pretty_flags(flags: int) -> str: ...
105-
def code_info(x: _HaveCodeOrStringType) -> str: ...
102+
def code_info(x: _HaveCodeType | str) -> str: ...
106103

107104
if sys.version_info >= (3, 11):
108105
def dis(
109-
x: _HaveCodeOrStringType | None = ...,
106+
x: _HaveCodeType | str | bytes | bytearray | None = ...,
110107
*,
111108
file: IO[str] | None = ...,
112109
depth: int | None = ...,
@@ -115,7 +112,9 @@ if sys.version_info >= (3, 11):
115112
) -> None: ...
116113

117114
else:
118-
def dis(x: _HaveCodeOrStringType | None = ..., *, file: IO[str] | None = ..., depth: int | None = ...) -> None: ...
115+
def dis(
116+
x: _HaveCodeType | str | bytes | bytearray | None = ..., *, file: IO[str] | None = ..., depth: int | None = ...
117+
) -> None: ...
119118

120119
if sys.version_info >= (3, 11):
121120
def disassemble(

0 commit comments

Comments
 (0)