Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Back out get_origin() parameter type #13999

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 9 commits into from
May 11, 2025
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 files.
Loading
Diff view
Diff view
Prev Previous commit
give up
  • Loading branch information
JelleZijlstra committed May 11, 2025
commit 32718fead9c6ad92924a177d587ac5c27939cabf
96 changes: 52 additions & 44 deletions 96 stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ if sys.version_info >= (3, 12):
if sys.version_info >= (3, 13):
__all__ += ["get_protocol_members", "is_protocol", "NoDefault", "TypeIs", "ReadOnly"]

# We can't use this name here because it leads to issues with mypy, likely
# due to an import cycle. Below instead we use Any with a comment.
# from _typeshed import AnnotationForm

class Any: ...
class _Final: ...

Expand All @@ -151,9 +155,9 @@ class TypeVar:
@property
def __name__(self) -> str: ...
@property
def __bound__(self) -> _AnnotationForm | None: ...
def __bound__(self) -> Any | None: ... # AnnotationForm
@property
def __constraints__(self) -> tuple[_AnnotationForm, ...]: ...
def __constraints__(self) -> tuple[Any, ...]: ... # AnnotationForm
@property
def __covariant__(self) -> bool: ...
@property
Expand All @@ -163,24 +167,24 @@ class TypeVar:
def __infer_variance__(self) -> bool: ...
if sys.version_info >= (3, 13):
@property
def __default__(self) -> _AnnotationForm: ...
def __default__(self) -> Any: ... # AnnotationForm
if sys.version_info >= (3, 13):
def __new__(
cls,
name: str,
*constraints: _AnnotationForm,
bound: _AnnotationForm | None = None,
*constraints: Any, # AnnotationForm
bound: Any | None = None, # AnnotationForm
contravariant: bool = False,
covariant: bool = False,
infer_variance: bool = False,
default: _AnnotationForm = ...,
default: Any = ..., # AnnotationForm
) -> Self: ...
elif sys.version_info >= (3, 12):
def __new__(
cls,
name: str,
*constraints: _AnnotationForm,
bound: _AnnotationForm | None = None,
*constraints: Any, # AnnotationForm
bound: Any | None = None, # AnnotationForm
covariant: bool = False,
contravariant: bool = False,
infer_variance: bool = False,
Expand All @@ -189,23 +193,23 @@ class TypeVar:
def __new__(
cls,
name: str,
*constraints: _AnnotationForm,
bound: _AnnotationForm | None = None,
*constraints: Any, # AnnotationForm
bound: Any | None = None, # AnnotationForm
covariant: bool = False,
contravariant: bool = False,
) -> Self: ...
else:
def __init__(
self,
name: str,
*constraints: _AnnotationForm,
bound: _AnnotationForm | None = None,
*constraints: Any, # AnnotationForm
bound: Any | None = None, # AnnotationForm
covariant: bool = False,
contravariant: bool = False,
) -> None: ...
if sys.version_info >= (3, 10):
def __or__(self, right: _AnnotationForm) -> _SpecialForm: ...
def __ror__(self, left: _AnnotationForm) -> _SpecialForm: ...
def __or__(self, right: Any) -> _SpecialForm: ... # AnnotationForm
def __ror__(self, left: Any) -> _SpecialForm: ... # AnnotationForm
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Any) -> Any: ...
if sys.version_info >= (3, 13):
Expand Down Expand Up @@ -260,10 +264,10 @@ if sys.version_info >= (3, 11):
def __name__(self) -> str: ...
if sys.version_info >= (3, 13):
@property
def __default__(self) -> _AnnotationForm: ...
def __default__(self) -> Any: ... # AnnotationForm
def has_default(self) -> bool: ...
if sys.version_info >= (3, 13):
def __new__(cls, name: str, *, default: _AnnotationForm = ...) -> Self: ...
def __new__(cls, name: str, *, default: Any = ...) -> Self: ... # AnnotationForm
elif sys.version_info >= (3, 12):
def __new__(cls, name: str) -> Self: ...
else:
Expand Down Expand Up @@ -306,7 +310,7 @@ if sys.version_info >= (3, 10):
@property
def __name__(self) -> str: ...
@property
def __bound__(self) -> _AnnotationForm | None: ...
def __bound__(self) -> Any | None: ... # AnnotationForm
@property
def __covariant__(self) -> bool: ...
@property
Expand All @@ -316,35 +320,45 @@ if sys.version_info >= (3, 10):
def __infer_variance__(self) -> bool: ...
if sys.version_info >= (3, 13):
@property
def __default__(self) -> _AnnotationForm: ...
def __default__(self) -> Any: ... # AnnotationForm
if sys.version_info >= (3, 13):
def __new__(
cls,
name: str,
*,
bound: _AnnotationForm | None = None,
bound: Any | None = None, # AnnotationForm
contravariant: bool = False,
covariant: bool = False,
infer_variance: bool = False,
default: _AnnotationForm = ...,
default: Any = ..., # AnnotationForm
) -> Self: ...
elif sys.version_info >= (3, 12):
def __new__(
cls,
name: str,
*,
bound: _AnnotationForm | None = None,
bound: Any | None = None, # AnnotationForm
contravariant: bool = False,
covariant: bool = False,
infer_variance: bool = False,
) -> Self: ...
elif sys.version_info >= (3, 11):
def __new__(
cls, name: str, *, bound: _AnnotationForm | None = None, contravariant: bool = False, covariant: bool = False
cls,
name: str,
*,
bound: Any | None = None, # AnnotationForm
contravariant: bool = False,
covariant: bool = False,
) -> Self: ...
else:
def __init__(
self, name: str, *, bound: _AnnotationForm | None = None, contravariant: bool = False, covariant: bool = False
self,
name: str,
*,
bound: Any | None = None, # AnnotationForm
contravariant: bool = False,
covariant: bool = False,
) -> None: ...

@property
Expand All @@ -368,7 +382,7 @@ if sys.version_info >= (3, 10):
TypeGuard: _SpecialForm

class NewType:
def __init__(self, name: str, tp: _AnnotationForm) -> None: ...
def __init__(self, name: str, tp: Any) -> None: ... # AnnotationForm
if sys.version_info >= (3, 11):
@staticmethod
def __call__(x: _T, /) -> _T: ...
Expand Down Expand Up @@ -901,17 +915,17 @@ if sys.version_info >= (3, 14):
include_extras: bool = False,
*,
format: Format | None = None,
) -> dict[str, _AnnotationForm]: ...
) -> dict[str, Any]: ... # AnnotationForm

else:
def get_type_hints(
obj: _get_type_hints_obj_allowed_types,
globalns: dict[str, Any] | None = None,
localns: Mapping[str, Any] | None = None,
include_extras: bool = False,
) -> dict[str, _AnnotationForm]: ...
) -> dict[str, Any]: ... # AnnotationForm

def get_args(tp: _AnnotationForm) -> tuple[_AnnotationForm, ...]: ...
def get_args(tp: Any) -> tuple[Any, ...]: ... # AnnotationForm

if sys.version_info >= (3, 10):
@overload
Expand All @@ -922,7 +936,7 @@ if sys.version_info >= (3, 10):
@overload
def get_origin(tp: GenericAlias) -> type: ...
@overload
def get_origin(tp: _AnnotationForm) -> _AnnotationForm | None: ...
def get_origin(tp: Any) -> Any | None: ... # AnnotationForm
@overload
def cast(typ: type[_T], val: Any) -> _T: ...
@overload
Expand All @@ -933,7 +947,7 @@ def cast(typ: object, val: Any) -> Any: ...
if sys.version_info >= (3, 11):
def reveal_type(obj: _T, /) -> _T: ...
def assert_never(arg: Never, /) -> Never: ...
def assert_type(val: _T, typ: _AnnotationForm, /) -> _T: ...
def assert_type(val: _T, typ: Any, /) -> _T: ... # AnnotationForm
def clear_overloads() -> None: ...
def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ...
def dataclass_transform(
Expand Down Expand Up @@ -1020,15 +1034,15 @@ if sys.version_info >= (3, 14):
locals: Mapping[str, Any] | None = None,
type_params: tuple[TypeVar, ParamSpec, TypeVarTuple] | None = None,
format: Format | None = None,
) -> _AnnotationForm: ...
) -> Any: ... # AnnotationForm

else:
@final
class ForwardRef(_Final):
__forward_arg__: str
__forward_code__: CodeType
__forward_evaluated__: bool
__forward_value__: _AnnotationForm | None
__forward_value__: Any | None # AnnotationForm
__forward_is_argument__: bool
__forward_is_class__: bool
__forward_module__: Any | None
Expand All @@ -1044,7 +1058,7 @@ else:
)
def _evaluate(
self, globalns: dict[str, Any] | None, localns: Mapping[str, Any] | None, *, recursive_guard: frozenset[str]
) -> _AnnotationForm | None: ...
) -> Any | None: ... # AnnotationForm
@overload
def _evaluate(
self,
Expand All @@ -1053,7 +1067,7 @@ else:
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...],
*,
recursive_guard: frozenset[str],
) -> _AnnotationForm | None: ...
) -> Any | None: ... # AnnotationForm
elif sys.version_info >= (3, 12):
def _evaluate(
self,
Expand All @@ -1062,11 +1076,11 @@ else:
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] | None = None,
*,
recursive_guard: frozenset[str],
) -> _AnnotationForm | None: ...
) -> Any | None: ... # AnnotationForm
else:
def _evaluate(
self, globalns: dict[str, Any] | None, localns: Mapping[str, Any] | None, recursive_guard: frozenset[str]
) -> _AnnotationForm | None: ...
) -> Any | None: ... # AnnotationForm

def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
Expand All @@ -1085,17 +1099,17 @@ if sys.version_info >= (3, 12):
class TypeAliasType:
def __new__(cls, name: str, value: Any, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ()) -> Self: ...
@property
def __value__(self) -> _AnnotationForm: ...
def __value__(self) -> Any: ... # AnnotationForm
@property
def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ...
@property
def __parameters__(self) -> tuple[_AnnotationForm, ...]: ...
def __parameters__(self) -> tuple[Any, ...]: ... # AnnotationForm
@property
def __name__(self) -> str: ...
# It's writable on types, but not on instances of TypeAliasType.
@property
def __module__(self) -> str | None: ... # type: ignore[override]
def __getitem__(self, parameters: _AnnotationForm) -> GenericAlias: ...
def __getitem__(self, parameters: Any) -> GenericAlias: ... # AnnotationForm
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 14):
Expand All @@ -1111,9 +1125,3 @@ if sys.version_info >= (3, 13):
NoDefault: _NoDefaultType
TypeIs: _SpecialForm
ReadOnly: _SpecialForm

# Objects that appear in annotations or in type expressions.
# Similar to PEP 747's TypeForm but a little broader.
# Duplicated from _typeshed.AnnotationForm; using it directly causes import cycle issues.
# See https://github.com/python/typeshed/pull/13999
_AnnotationForm: typing_extensions.TypeAlias = Any
Morty Proxy This is a proxified and sanitized view of the page, visit original site.