mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
gh-105499: Defer "import warnings" in typing (#132061)
A bunch of other warnings in typing.py were already deferred, but I added a few non-lazy ones.
This commit is contained in:
parent
20098719df
commit
d1db43c139
1 changed files with 4 additions and 1 deletions
|
|
@ -30,7 +30,6 @@
|
|||
import sys
|
||||
import types
|
||||
from types import GenericAlias
|
||||
import warnings
|
||||
|
||||
from _typing import (
|
||||
_idfunc,
|
||||
|
|
@ -1626,14 +1625,17 @@ def __getitem__(self, params):
|
|||
|
||||
class _UnionGenericAliasMeta(type):
|
||||
def __instancecheck__(self, inst: object) -> bool:
|
||||
import warnings
|
||||
warnings._deprecated("_UnionGenericAlias", remove=(3, 17))
|
||||
return isinstance(inst, Union)
|
||||
|
||||
def __subclasscheck__(self, inst: type) -> bool:
|
||||
import warnings
|
||||
warnings._deprecated("_UnionGenericAlias", remove=(3, 17))
|
||||
return issubclass(inst, Union)
|
||||
|
||||
def __eq__(self, other):
|
||||
import warnings
|
||||
warnings._deprecated("_UnionGenericAlias", remove=(3, 17))
|
||||
if other is _UnionGenericAlias or other is Union:
|
||||
return True
|
||||
|
|
@ -1650,6 +1652,7 @@ class _UnionGenericAlias(metaclass=_UnionGenericAliasMeta):
|
|||
|
||||
"""
|
||||
def __new__(cls, self_cls, parameters, /, *, name=None):
|
||||
import warnings
|
||||
warnings._deprecated("_UnionGenericAlias", remove=(3, 17))
|
||||
return Union[parameters]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue