From b8bea1b2c91561cca342b6507dfc93b7c90f9ce1 Mon Sep 17 00:00:00 2001 From: Mehdi Drissi Date: Tue, 25 Jan 2022 04:03:54 -0600 Subject: [PATCH] Improve trait signature in mypy_extensions.pyi (#7027) Co-authored-by: Mehdi Drissi --- stubs/mypy-extensions/mypy_extensions.pyi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stubs/mypy-extensions/mypy_extensions.pyi b/stubs/mypy-extensions/mypy_extensions.pyi index 89f312336..225415a59 100644 --- a/stubs/mypy-extensions/mypy_extensions.pyi +++ b/stubs/mypy-extensions/mypy_extensions.pyi @@ -38,9 +38,10 @@ def KwArg(type: _T = ...) -> _T: ... # Deprecated: Use typing.NoReturn instead. class NoReturn: ... -# This is intended as a class decorator, but mypy rejects abstract classes -# when a Type[_T] is expected, so we can't give it the type we want -def trait(cls: Any) -> Any: ... +# This is consistent with implementation. Usage intends for this as +# a class decorator, but mypy does not support type[_T] for abstract +# classes until this issue is resolved, https://github.com/python/mypy/issues/4717. +def trait(cls: _T) -> _T: ... def mypyc_attr(*attrs: str, **kwattrs: object) -> Callable[[_T], _T]: ... class FlexibleAlias(Generic[_T, _U]): ...