Skip to content

Conversation

@jorenham
Copy link
Member

Follow-up of #29695 and #29706, resolving python/mypy#15993 (comment)

@github-actions
Copy link

Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code:

freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__call__" of "_FloatOp" matches argument type "str"  [call-overload]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__rsub__" of "floating" matches argument type "str"  [operator]
+ freqtrade/data/converter/orderflow.py:175: note:     def __rsub__(self, int | floating[_16Bit] | unsignedinteger[_8Bit] | signedinteger[_8Bit] | numpy.bool[builtins.bool], /) -> floating[Any]
+ freqtrade/data/converter/orderflow.py:175: note:     def __rsub__(self, integer[Any] | floating[Any], /) -> floating[Any]
- freqtrade/data/converter/orderflow.py:175: note:     def __call__(self, int, /) -> floating[Any]
+ freqtrade/data/converter/orderflow.py:175: note:     def __rsub__(self, float, /) -> floating[Any]
- freqtrade/data/converter/orderflow.py:175: note:     def __call__(self, float, /) -> floating[Any] | float64
- freqtrade/data/converter/orderflow.py:175: note:     def __call__(self, complex, /) -> complexfloating[Any, Any] | complex128
+ freqtrade/data/converter/orderflow.py:175: note:     def __rsub__(self, complex, /) -> complexfloating[Any, Any]
- freqtrade/data/converter/orderflow.py:175: note:     def [_NBit2: NBitBase] __call__(self, integer[_NBit2] | floating[_NBit2], /) -> floating[Any] | floating[_NBit2]
- freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__call__" of "_FloatOp" matches argument type "bytes"  [call-overload]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__rsub__" of "floating" matches argument type "bytes"  [operator]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "floating" matches argument type "str"  [operator]
+ freqtrade/data/converter/orderflow.py:175: note:     def __sub__(self, int | floating[_16Bit] | unsignedinteger[_8Bit] | signedinteger[_8Bit] | numpy.bool[builtins.bool] | floating[Any], /) -> floating[Any]
+ freqtrade/data/converter/orderflow.py:175: note:     def __sub__(self, integer[Any] | floating[Any], /) -> floating[Any]
+ freqtrade/data/converter/orderflow.py:175: note:     def __sub__(self, float, /) -> floating[Any]
+ freqtrade/data/converter/orderflow.py:175: note:     def __sub__(self, complex, /) -> complexfloating[Any, Any]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "floating" matches argument type "bytes"  [operator]
- freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__call__" of "_FloatOp" matches argument type "date"  [call-overload]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "floating" matches argument type "date"  [operator]
- freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__call__" of "_FloatOp" matches argument type "datetime"  [call-overload]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "floating" matches argument type "datetime"  [operator]
- freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__call__" of "_FloatOp" matches argument type "timedelta"  [call-overload]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "floating" matches argument type "timedelta"  [operator]
- freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__call__" of "_FloatOp" matches argument type "datetime64[date | int | None]"  [call-overload]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "floating" matches argument type "datetime64[date | int | None]"  [operator]
- freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__call__" of "_FloatOp" matches argument type "timedelta64[timedelta | int | None]"  [call-overload]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "floating" matches argument type "timedelta64[timedelta | int | None]"  [operator]
- freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__call__" of "_FloatOp" matches argument type "Timestamp"  [call-overload]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "floating" matches argument type "Timestamp"  [operator]
- freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__call__" of "_FloatOp" matches argument type "Timedelta"  [call-overload]
+ freqtrade/data/converter/orderflow.py:175: error: No overload variant of "__sub__" of "floating" matches argument type "Timedelta"  [operator]

scipy-stubs (https://github.com/scipy/scipy-stubs)
+ scipy-stubs/signal/_ltisys.pyi:388: error: Unused "type: ignore" comment  [unused-ignore]
+ scipy-stubs/signal/_ltisys.pyi:389: error: Unused "type: ignore" comment  [unused-ignore]
+ scipy-stubs/signal/_ltisys.pyi:390: error: Unused "type: ignore" comment  [unused-ignore]

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/_libs/tslibs/timestamps.pyi:182: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas-stubs/_libs/tslibs/timestamps.pyi:192: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas-stubs/_libs/tslibs/timestamps.pyi:202: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas-stubs/_libs/tslibs/timestamps.pyi:212: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas-stubs/_libs/tslibs/timedeltas.pyi:356: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas-stubs/_libs/tslibs/timedeltas.pyi:367: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas-stubs/_libs/tslibs/timedeltas.pyi:378: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas-stubs/_libs/tslibs/timedeltas.pyi:389: error: Unused "type: ignore" comment  [unused-ignore]

@jorenham
Copy link
Member Author

jorenham commented Sep 10, 2025

I like the mypy_primer diffs.

For freqtrade it's safe to ignore, because it's just showing that the reported error code changed for a single line.
For pandas-stubs and scipy-stubs1 this is good news, since they can remove a bunch of # type ignores with this.

Footnotes

  1. Wow what an amazing package! I wonder who wrote it... 😏

@jorenham jorenham marked this pull request as ready for review September 10, 2025 17:35
@jorenham jorenham added the 09 - Backport-Candidate PRs tagged should be backported label Sep 10, 2025
@charris charris merged commit 8754b78 into numpy:main Sep 11, 2025
80 checks passed
@charris
Copy link
Member

charris commented Sep 11, 2025

Thanks Joren.

@jorenham jorenham deleted the typing/inline-floating-methods branch September 11, 2025 16:15
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants