-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(python): Change method op type hints to match dunder op type hints
Type hints for operators were refined in #13635 [0], but the refinements were generally not propagated to the method equivalents (pow() being the sole exception). This can result in equivalent expressions being treated differently by type checkers, especially if stricter settings are used that discourage/disallow the use of Any. This commit changes the type hints for the method equivalents to match those for the operators. This should ensure resulting types are consistent regardless of whether one uses infix operators or their method equivalents. This also has the side benefit of making the documentation a bit more consistent as the type hint more closely matches the stated type of the argument in the docstring. Not entirely sure whether the type: ignore hints are necessary or whether there's some alternative formulation which doesn't require them. I believe the override should be sound in this instance since the expr.or_(expr, ...) should be equivalent to expr | expr | ..., and the type signature for or_() was changed to be the same as for __bitor__ (and a similar argument applies to and_()/__bitand__). [0]: 1c417e4
- Loading branch information
Alex Wang
committed
Oct 22, 2024
1 parent
e8cfa44
commit 604988d
Showing
1 changed file
with
19 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters