Skip to content

Commit 31dca1d

Browse files
authored
Update inspect for Python3.12 (#10398)
1 parent 18d45d6 commit 31dca1d

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

stdlib/inspect.pyi

+27
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,21 @@ if sys.version_info >= (3, 11):
128128
"walktree",
129129
]
130130

131+
if sys.version_info >= (3, 12):
132+
__all__ += [
133+
"markcoroutinefunction",
134+
"AGEN_CLOSED",
135+
"AGEN_CREATED",
136+
"AGEN_RUNNING",
137+
"AGEN_SUSPENDED",
138+
"getasyncgenlocals",
139+
"getasyncgenstate",
140+
"BufferFlags",
141+
]
142+
131143
_P = ParamSpec("_P")
132144
_T = TypeVar("_T")
145+
_F = TypeVar("_F", bound=Callable[..., Any])
133146
_T_cont = TypeVar("_T_cont", contravariant=True)
134147
_V_cont = TypeVar("_V_cont", contravariant=True)
135148

@@ -184,6 +197,9 @@ def isclass(object: object) -> TypeGuard[type[Any]]: ...
184197
def ismethod(object: object) -> TypeGuard[MethodType]: ...
185198
def isfunction(object: object) -> TypeGuard[FunctionType]: ...
186199

200+
if sys.version_info >= (3, 12):
201+
def markcoroutinefunction(func: _F) -> _F: ...
202+
187203
if sys.version_info >= (3, 8):
188204
@overload
189205
def isgeneratorfunction(obj: Callable[..., Generator[Any, Any, Any]]) -> bool: ...
@@ -360,6 +376,17 @@ class _ParameterKind(enum.IntEnum):
360376
@property
361377
def description(self) -> str: ...
362378

379+
if sys.version_info >= (3, 12):
380+
AGEN_CREATED: Literal["AGEN_CREATED"]
381+
AGEN_RUNNING: Literal["AGEN_RUNNING"]
382+
AGEN_SUSPENDED: Literal["AGEN_SUSPENDED"]
383+
AGEN_CLOSED: Literal["AGEN_CLOSED"]
384+
385+
def getasyncgenstate(
386+
agen: AsyncGenerator[Any, Any]
387+
) -> Literal["AGEN_CREATED", "AGEN_RUNNING", "AGEN_SUSPENDED", "AGEN_CLOSED"]: ...
388+
def getasyncgenlocals(agen: AsyncGeneratorType[Any, Any]) -> dict[str, Any]: ...
389+
363390
class Parameter:
364391
def __init__(self, name: str, kind: _ParameterKind, *, default: Any = ..., annotation: Any = ...) -> None: ...
365392
empty = _empty

tests/stubtest_allowlists/py312.txt

-8
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ importlib.resources.files
5353
importlib.util.module_for_loader
5454
importlib.util.set_loader
5555
importlib.util.set_package
56-
inspect.AGEN_CLOSED
57-
inspect.AGEN_CREATED
58-
inspect.AGEN_RUNNING
59-
inspect.AGEN_SUSPENDED
60-
inspect.__all__
61-
inspect.getasyncgenlocals
62-
inspect.getasyncgenstate
63-
inspect.markcoroutinefunction
6456
logging.Logger.getChildren
6557
logging.__all__
6658
logging.getHandlerByName

0 commit comments

Comments
 (0)