Fully type _operator module#15612
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
JelleZijlstra
left a comment
There was a problem hiding this comment.
You can add test cases in stdlib/@tests/test_cases, though we generally do so only in exceptionally complicated cases and I'm not sure any of the changes here need them.
It would also be helpful to look over the mypy-primer results and see if the changes are desirable.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
No idea why the stubtest failures are emerging... |
It's unrelated to your PR. New Python patch releases came out overnight, and it looks like our CI runners have just started using them. I can add a temporary pin to our CI workflow to get things green again, one sec |
This comment has been minimized.
This comment has been minimized.
|
Since flake8-pyi#539 is progressing much faster than I expected, maybe hold off merging this until that is resolved, then I can remove the |
|
Sorry, I accidentally made a commit to the wrong branch. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some weird new errors are emerging, and I can't understand them. Is it a problem with mypy? Because I didn't change anything. |
|
The _binary_ops_dict thing seems nondeterministic and I think it's caused by previous recent changes to operator. See python/mypy#21445 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Diff from mypy_primer, showing the effect of this PR on open source code: kornia (https://github.com/kornia/kornia)
+ kornia/feature/sold2/backbones.py:79: error: Argument 1 to "reduce" has incompatible type "Callable[[MutableSequence[_T], Sequence[_T]], MutableSequence[_T]]"; expected "Callable[[list[int], list[int]], list[int]]" [arg-type]
colour (https://github.com/colour-science/colour)
+ colour/io/luts/lut.py:642: error: Cannot call function of unknown type [operator]
+ colour/continuous/signal.py:1093: error: Cannot call function of unknown type [operator]
+ colour/continuous/signal.py:1097: error: Cannot call function of unknown type [operator]
schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/cli/validation.py: note: In function "reduce_list":
+ src/schemathesis/cli/validation.py:184: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[list[Never], list[str]], list[Never]]" [arg-type]
pandas (https://github.com/pandas-dev/pandas)
- pandas/core/roperator.py:56: error: Call to untyped function "and_" in typed context [no-untyped-call]
- pandas/core/roperator.py:60: error: Call to untyped function "or_" in typed context [no-untyped-call]
- pandas/core/roperator.py:64: error: Call to untyped function "xor" in typed context [no-untyped-call]
+ pandas/core/computation/ops.py:328: error: Need type annotation for "_binary_ops_dict" (hint: "_binary_ops_dict: dict[<type>, <type>] = ...") [var-annotated]
+ pandas/core/algorithms.py:1368: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function) [assignment]
+ pandas/core/indexes/datetimes.py:1468: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function) [assignment]
xarray (https://github.com/pydata/xarray)
+ xarray/core/accessor_str.py: note: In member "get_dummies" of class "StringAccessor":
+ xarray/core/accessor_str.py:2836: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[Iterable[Any], Iterable[Any]], Iterable[Any]]" [arg-type]
ibis (https://github.com/ibis-project/ibis)
+ ibis/util.py:268: error: Incompatible types in assignment (expression has type "overloaded function | overloaded function", variable has type overloaded function) [assignment]
+ ibis/expr/api.py:746: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[BooleanValue | bool, BooleanValue | bool], BooleanValue | bool]" [arg-type]
+ ibis/expr/api.py:766: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[BooleanValue | bool, BooleanValue | bool], BooleanValue | bool]" [arg-type]
+ ibis/backends/sql/compilers/base.py:633: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[Replace, Replace], Replace]" [arg-type]
jax (https://github.com/google/jax)
- jax/_src/pallas/pipelining/schedulers.py:236: error: Argument 1 to "reduce" has incompatible type "BinaryUfunc | Callable[[Any, Any], Any]"; expected "Callable[[bool, Array | bool], bool]" [arg-type]
+ jax/_src/pallas/pipelining/schedulers.py:236: error: Argument 1 to "reduce" has incompatible type "BinaryUfunc | overloaded function"; expected "Callable[[bool, Array | bool], bool]" [arg-type]
- jax/_src/pallas/pipelining/schedulers.py:265: error: Incompatible types in assignment (expression has type "Array | Any", variable has type "bool") [assignment]
+ jax/_src/pallas/pipelining/schedulers.py:265: error: Incompatible types in assignment (expression has type "object", variable has type "bool") [assignment]
- jax/_src/pallas/pipelining/schedulers.py:272: error: Incompatible types in assignment (expression has type "Array | Any", variable has type "bool") [assignment]
+ jax/_src/pallas/pipelining/schedulers.py:272: error: Incompatible types in assignment (expression has type "object", variable has type "bool") [assignment]
- jax/_src/pallas/pipelining/schedulers.py:298: error: Argument 1 to "reduce" has incompatible type "BinaryUfunc | Callable[[Any, Any], Any]"; expected "Callable[[list[Array | bool], Array | bool], list[Array | bool]]" [arg-type]
+ jax/_src/pallas/pipelining/schedulers.py:298: error: Argument 1 to "reduce" has incompatible type "BinaryUfunc | overloaded function"; expected "Callable[[list[Array | bool], Array | bool], list[Array | bool]]" [arg-type]
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py: note: In member "should_suppress_value_header" of class "DataDocumenter":
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py:2078:44: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[list[Never], list[str]], list[Never]]" [arg-type]
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py:2078:44: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[Iterable[str], list[str]], Iterable[str]]" [arg-type]
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py: note: In member "should_suppress_value_header" of class "AttributeDocumenter":
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py:2730:48: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[list[Never], list[str]], list[Never]]" [arg-type]
+ sphinx/ext/autodoc/_legacy_class_based/_documenters.py:2730:48: error: Argument 1 to "reduce" has incompatible type overloaded function; expected "Callable[[Iterable[str], list[str]], Iterable[str]]" [arg-type]
|
|
Will this be merged soon? I have no idea how I would target any of the new mypy_primer errors. |
|
Sorry, I accidentally deleted this branch again. Will open another PR. |
Closes: #15611, #15617.