Skip to content

Commit

Permalink
Update inspect for Python3.12 (#10398)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Jul 3, 2023
1 parent 18d45d6 commit 31dca1d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
27 changes: 27 additions & 0 deletions stdlib/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,21 @@ if sys.version_info >= (3, 11):
"walktree",
]

if sys.version_info >= (3, 12):
__all__ += [
"markcoroutinefunction",
"AGEN_CLOSED",
"AGEN_CREATED",
"AGEN_RUNNING",
"AGEN_SUSPENDED",
"getasyncgenlocals",
"getasyncgenstate",
"BufferFlags",
]

_P = ParamSpec("_P")
_T = TypeVar("_T")
_F = TypeVar("_F", bound=Callable[..., Any])
_T_cont = TypeVar("_T_cont", contravariant=True)
_V_cont = TypeVar("_V_cont", contravariant=True)

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

if sys.version_info >= (3, 12):
def markcoroutinefunction(func: _F) -> _F: ...

if sys.version_info >= (3, 8):
@overload
def isgeneratorfunction(obj: Callable[..., Generator[Any, Any, Any]]) -> bool: ...
Expand Down Expand Up @@ -360,6 +376,17 @@ class _ParameterKind(enum.IntEnum):
@property
def description(self) -> str: ...

if sys.version_info >= (3, 12):
AGEN_CREATED: Literal["AGEN_CREATED"]
AGEN_RUNNING: Literal["AGEN_RUNNING"]
AGEN_SUSPENDED: Literal["AGEN_SUSPENDED"]
AGEN_CLOSED: Literal["AGEN_CLOSED"]

def getasyncgenstate(
agen: AsyncGenerator[Any, Any]
) -> Literal["AGEN_CREATED", "AGEN_RUNNING", "AGEN_SUSPENDED", "AGEN_CLOSED"]: ...
def getasyncgenlocals(agen: AsyncGeneratorType[Any, Any]) -> dict[str, Any]: ...

class Parameter:
def __init__(self, name: str, kind: _ParameterKind, *, default: Any = ..., annotation: Any = ...) -> None: ...
empty = _empty
Expand Down
8 changes: 0 additions & 8 deletions tests/stubtest_allowlists/py312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ importlib.resources.files
importlib.util.module_for_loader
importlib.util.set_loader
importlib.util.set_package
inspect.AGEN_CLOSED
inspect.AGEN_CREATED
inspect.AGEN_RUNNING
inspect.AGEN_SUSPENDED
inspect.__all__
inspect.getasyncgenlocals
inspect.getasyncgenstate
inspect.markcoroutinefunction
logging.Logger.getChildren
logging.__all__
logging.getHandlerByName
Expand Down

0 comments on commit 31dca1d

Please sign in to comment.