mypy
mypy copied to clipboard
Improve decorator type error message for decorated functions (#16295)
This PR is related with the issue #16295
Checklist:
- Clarifies error reporting when a decorator (or decorator factory) supplies an incompatible callable signature, including the decorated function’s name.
- Adds regression test for decorator factory application to verify the detailed message.
Diff from mypy_primer, showing the effect of this PR on open source code:
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/client/schemas/objects.py:306: error: Argument 1 has incompatible type "Callable[[State[R], bool, bool], R | Exception]"; expected "Callable[[State[R], Literal[True], bool], R]" [arg-type]
+ src/prefect/client/schemas/objects.py:306: error: Decorated function "result" has incompatible type "Callable[[State[R], bool, bool], R | Exception]"; expected "Callable[[State[R], Literal[True], bool], R]" [arg-type]
Diff from mypy_primer, showing the effect of this PR on open source code:
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/client/schemas/objects.py:306: error: Argument 1 has incompatible type "Callable[[State[R], bool, bool], R | Exception]"; expected "Callable[[State[R], Literal[True], bool], R]" [arg-type]
+ src/prefect/client/schemas/objects.py:306: error: Decorated function "result" has incompatible type "Callable[[State[R], bool, bool], R | Exception]"; expected "Callable[[State[R], Literal[True], bool], R]" [arg-type]
Diff from mypy_primer, showing the effect of this PR on open source code:
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/client/schemas/objects.py:306: error: Argument 1 has incompatible type "Callable[[State[R], bool, bool], R | Exception]"; expected "Callable[[State[R], Literal[True], bool], R]" [arg-type]
+ src/prefect/client/schemas/objects.py:306: error: Decorated function "result" has incompatible type "Callable[[State[R], bool, bool], R | Exception]"; expected "Callable[[State[R], Literal[True], bool], R]" [arg-type]