8000 `inspect`, `asyncio`: Use more `TypeGuard`s by AlexWaygood · Pull Request #8057 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

inspect, asyncio: Use more TypeGuards #8057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load 8000 files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'master' into iscoroutinefunction
  • Loading branch information
AlexWaygood authored Jul 11, 2022
commit 3aa62dd912ff655df9c872b0d0141c9c68cce1c2
51 changes: 15 additions & 36 deletions stdlib/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,8 @@ from types import (
TracebackType,
WrapperDescriptorType,
)
from typing_extensions import TypeAlias

if sys.version_info >= (3, 7):
from types import (
ClassMethodDescriptorType,
WrapperDescriptorType,
MemberDescriptorType,
MethodDescriptorType,
MethodWrapperType,
)

from typing import Any, ClassVar, NamedTuple, Protocol, TypeVar, Union, overload
from typing_extensions import Literal, ParamSpec, TypeGuard
from typing_extensions import Literal, ParamSpec, TypeAlias, TypeGuard

if sys.version_info >= (3, 11):
__all__ = [
Expand Down Expand Up @@ -254,30 +243,20 @@ def isbuiltin(object: object) -> TypeGuard[BuiltinFunctionType]: ...
if sys.version_info >= (3, 11):
def ismethodwrapper(object: object) -> TypeGuard[MethodWrapperType]: ...

if sys.version_info >= (3, 7):
_Routine: TypeAlias = (
FunctionType
| LambdaType
| MethodType
| BuiltinFunctionType
| BuiltinMethodType
| WrapperDescriptorType
| MethodDescriptorType
| ClassMethodDescriptorType
)
else:
_Routine: TypeAlias = FunctionType | LambdaType | MethodType | BuiltinFunctionType | BuiltinMethodType

def isroutine(object: object) -> TypeGuard[_Routine]: ...

if sys.version_info >= (3, 7):
def ismethoddescriptor(object: object) -> TypeGuard[MethodDescriptorType]: ...
def ismemberdescriptor(object: object) -> TypeGuard[MemberDescriptorType]: ...

else:
def ismethoddescriptor(object: object) -> bool: ...
def ismemberdescriptor(object: object) -> bool: ...

def isroutine(
object: object,
) -> TypeGuard[
FunctionType
| LambdaType
| MethodType
| BuiltinFunctionType
| BuiltinMethodType
| WrapperDescriptorType
| MethodDescriptorType
| ClassMethodDescriptorType
]: ...
def ismethoddescriptor(object: object) -> TypeGuard[MethodDescriptorType]: ...
def ismemberdescriptor(object: object) -> TypeGuard[MemberDescriptorType]: ...
def isabstract(object: object) -> bool: ...
def isgetsetdescriptor(object: object) -> TypeGuard[GetSetDescriptorType]: ...
def isdatadescriptor(object: object) -> TypeGuard[_SupportsSet[Any, Any] | _SupportsDelete[Any]]: ...
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0