From 59b72612d5fbfa735e7a9c6c1038444150467692 Mon Sep 17 00:00:00 2001 From: layday Date: Sat, 19 Dec 2020 03:30:23 +0200 Subject: [PATCH] Fix nested decorator annotation Type checkers cannot solve an aliased, generic callable. --- nox/registry.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nox/registry.py b/nox/registry.py index 3bf74a78..f08b188a 100644 --- a/nox/registry.py +++ b/nox/registry.py @@ -21,7 +21,6 @@ from ._typing import Python F = TypeVar("F", bound=Callable[..., Any]) -G = Callable[[F], F] _REGISTRY = collections.OrderedDict() # type: collections.OrderedDict[str, Func] @@ -40,7 +39,7 @@ def session_decorator( name: Optional[str] = ..., venv_backend: Any = ..., venv_params: Any = ..., -) -> G: +) -> Callable[[F], F]: ... @@ -52,7 +51,7 @@ def session_decorator( name: Optional[str] = None, venv_backend: Any = None, venv_params: Any = None, -) -> Union[F, G]: +) -> Union[F, Callable[[F], F]]: """Designate the decorated function as a session.""" # If `func` is provided, then this is the decorator call with the function # being sent as part of the Python syntax (`@nox.session`).