We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Currently we use a custom mypy plugin to fix typings of some decorators. Plugin: https://github.com/dry-python/returns/blob/master/returns/contrib/mypy/_features/decorators.py
mypy
Progress: python/mypy#8645 PEP: https://www.python.org/dev/peps/pep-0612/ Source: https://github.com/python/cpython/blob/366dc3a1354078e38808b9c16276e97cca5b8aaf/Lib/typing.py#L730
Example:
from typing_extensions import ParamSpec from typing import TypeVar, Callable T = TypeVar('T') P = ParamSpec('P') def add_logging(f: Callable[P, T]) -> Callable[P, T]: '''A type-safe decorator to add logging to a function.''' def inner(*args: P.args, **kwargs: P.kwargs) -> T: logging.info(f'{f.__name__} was called') return f(*args, **kwargs) return inner @add_logging def add_two(x: float, y: float) -> float: '''Add two numbers together.''' return x + y
It is not working right now, we need to wait until proper support is merged into mypy.
The text was updated successfully, but these errors were encountered:
That's beautiful!!
Sorry, something went wrong.
Refs #264
@safe(exceptions=(TypeError, ValueError))
ParamSpec
Successfully merging a pull request may close this issue.
Currently we use a custom
mypy
plugin to fix typings of some decorators.Plugin: https://github.com/dry-python/returns/blob/master/returns/contrib/mypy/_features/decorators.py
Progress: python/mypy#8645
PEP: https://www.python.org/dev/peps/pep-0612/
Source: https://github.com/python/cpython/blob/366dc3a1354078e38808b9c16276e97cca5b8aaf/Lib/typing.py#L730
Example:
It is not working right now, we need to wait until proper support is merged into mypy.
The text was updated successfully, but these errors were encountered: