mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-06 21:43:59 +08:00
Add @type_check_only to stub-only private classes in stdlib (#14512)
This commit is contained in:
+4
-1
@@ -8,7 +8,7 @@
|
||||
# nor `float` as a subtype of `numbers.Real`, etc.)
|
||||
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import ClassVar, Literal, Protocol, overload
|
||||
from typing import ClassVar, Literal, Protocol, overload, type_check_only
|
||||
|
||||
__all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
|
||||
|
||||
@@ -22,6 +22,7 @@ __all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
|
||||
# NOTE: We can't include `__complex__` here,
|
||||
# as we want `int` to be seen as a subtype of `_ComplexLike`,
|
||||
# and `int.__complex__` does not exist :(
|
||||
@type_check_only
|
||||
class _ComplexLike(Protocol):
|
||||
def __neg__(self) -> _ComplexLike: ...
|
||||
def __pos__(self) -> _ComplexLike: ...
|
||||
@@ -29,6 +30,7 @@ class _ComplexLike(Protocol):
|
||||
|
||||
# _RealLike is a structural-typing approximation
|
||||
# of the `Real` ABC, which is not (and cannot be) a protocol
|
||||
@type_check_only
|
||||
class _RealLike(_ComplexLike, Protocol):
|
||||
def __trunc__(self) -> _IntegralLike: ...
|
||||
def __floor__(self) -> _IntegralLike: ...
|
||||
@@ -41,6 +43,7 @@ class _RealLike(_ComplexLike, Protocol):
|
||||
|
||||
# _IntegralLike is a structural-typing approximation
|
||||
# of the `Integral` ABC, which is not (and cannot be) a protocol
|
||||
@type_check_only
|
||||
class _IntegralLike(_RealLike, Protocol):
|
||||
def __invert__(self) -> _IntegralLike: ...
|
||||
def __int__(self) -> int: ...
|
||||
|
||||
Reference in New Issue
Block a user