Deprecation decorators messing with type checking #16962
Labels
A-typing
Area: type checking
bug
Something isn't working
needs decision
Awaiting decision by a maintainer
needs triage
Awaiting prioritization by a maintainer
python
Related to Python Polars
Checks
Reproducible example
Log output
No response
Issue description
Using the latest versions of polars, I noticed more and more type hint warnings, leading me to sprinkle my codebase with
# noqa
's... which I would like to avoid.It seems to come from decorated functions, in particular the ones deprecated for deprecation.
Indeed, the function returned by the decorator always has a signature with only one parameter called
P
, which is in general different from the original function signature.Screenshots from PyCharm below:
Expected behavior
The functions shouldn't raise type warnings in PyCharm.
A function decorated for deprecation should have the same signature as the same function non-decorated (maybe except for the deprecated parameters..?).
Searching the web for such problems I found the
decohints
package trying to solve this issue, maybe copying their approach would work..?Side Note
I wonder if it is possible to mimic the standard library modus operandum, at least for deprecated functions in Polars.
The hints for these deprecations are very explicit, screenshot & implementation below:
Installed versions
The text was updated successfully, but these errors were encountered: