mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Fix overly precise typing.NewType signature (#7474)
`type` is incorrect because `NewType` can also accept another `NewType`: https://peps.python.org/pep-0484/#newtype-helper-function The return type was also wrong; pre-3.10 `NewType()` doesn't return a type object.
This commit is contained in:
@@ -554,14 +554,14 @@ if sys.version_info >= (3, 10):
|
||||
TypeGuard: _SpecialForm
|
||||
|
||||
class NewType:
|
||||
def __init__(self, name: str, tp: type) -> None: ...
|
||||
def __init__(self, name: str, tp: Any) -> None: ...
|
||||
def __call__(self, x: _T) -> _T: ...
|
||||
def __or__(self, other: Any) -> _SpecialForm: ...
|
||||
def __ror__(self, other: Any) -> _SpecialForm: ...
|
||||
__supertype__: type
|
||||
|
||||
else:
|
||||
def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...
|
||||
def NewType(name: str, tp: Any) -> Any: ...
|
||||
|
||||
# These type variables are used by the container types.
|
||||
_S = TypeVar("_S")
|
||||
|
||||
Reference in New Issue
Block a user