Skip to content

Add proper type hints to class_decorator and decorator #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
smarie opened this issue Mar 1, 2022 · 1 comment
Closed

Add proper type hints to class_decorator and decorator #28

smarie opened this issue Mar 1, 2022 · 1 comment

Comments

@smarie
Copy link
Owner

smarie commented Mar 1, 2022

Ideally we should do the same than #23 for class_decorator and for decorator.

Note that _Decorator might need to change to support decorating Types too. Or, even more ideally, we would have a _FuncDecorator for function_decorator, a _ClassDecorator for class_decorator and a _Decorator = Union[_FuncDecorator, _ClassDecorator] for decorator.


# @class_decorator() is called without options or parenthesis
@overload
def class_decorator(
    enable_stack_introspection: Callable[P, Any],
    custom_disambiguator: Callable[[Any], FirstArgDisambiguation] = ...,
    flat_mode_decorated_name: Optional[str] = ...,
) -> _Decorator[P]: ...

# @class_decorator() is called with options or parenthesis.
@overload
def class_decorator(
    enable_stack_introspection: bool = ...,
    custom_disambiguator: Callable[[Any], FirstArgDisambiguation] = ...,
    flat_mode_decorated_name: Optional[str] = ...,
) -> Callable[[Callable[P, Any]], _Decorator[P]]: ...

Originally posted by @smarie in #23 (comment)

@smarie
Copy link
Owner Author

smarie commented Mar 1, 2022

Closing as duplicate - was already a step in #22

@smarie smarie closed this as completed Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant