Skip to content

Fully type _operator module#15612

Open
jonathandung wants to merge 4 commits intopython:mainfrom
jonathandung:main
Open

Fully type _operator module#15612
jonathandung wants to merge 4 commits intopython:mainfrom
jonathandung:main

Conversation

@jonathandung
Copy link
Copy Markdown
Contributor

Closes #15611.
This is a big change, my annotations may have some formatting issues, and I don't know how to add tests; however, I will not make this a draft to potentially get more suggestions.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Diff from mypy_primer, showing the effect of this PR on open source code:

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 "Callable[[_SupportsIAdd[_T_contra, _T_co], _T_contra], _T_co]"; 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 "Callable[[_SupportsIAdd[_T_contra, _T_co], _T_contra], _T_co]"; 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 "Callable[[_SupportsIAdd[_T_contra, _T_co], _T_contra], _T_co]"; 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 "Callable[[_SupportsIAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[Iterable[str], list[str]], Iterable[str]]"  [arg-type]

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]

Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/conversion.py:133: error: Argument 1 to "reduce" has incompatible type "Callable[[_SupportsIOr[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[CacheComponents, CacheComponents], CacheComponents]"  [arg-type]
+ tanjun/conversion.py:156: error: Argument 1 to "reduce" has incompatible type "Callable[[_SupportsIOr[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[Intents, Intents], Intents]"  [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 "Callable[[_SupportsIAdd[_T_contra, _T_co], _T_contra], _T_co]"; expected "Callable[[list[Never], list[str]], list[Never]]"  [arg-type]

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]

jax (https://github.com/google/jax)
- jax/_src/pallas/pipelining/schedulers.py:241: 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:241: 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:270: error: Incompatible types in assignment (expression has type "Array | Any", variable has type "bool")  [assignment]
+ jax/_src/pallas/pipelining/schedulers.py:270: error: Incompatible types in assignment (expression has type "object", variable has type "bool")  [assignment]
- jax/_src/pallas/pipelining/schedulers.py:277: error: Incompatible types in assignment (expression has type "Array | Any", variable has type "bool")  [assignment]
+ jax/_src/pallas/pipelining/schedulers.py:277: error: Incompatible types in assignment (expression has type "object", variable has type "bool")  [assignment]
- jax/_src/pallas/pipelining/schedulers.py:303: 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:303: error: Argument 1 to "reduce" has incompatible type "BinaryUfunc | overloaded function"; expected "Callable[[list[Array | bool], Array | bool], list[Array | bool]]"  [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]

pandas (https://github.com/pandas-dev/pandas)
+ 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:1346: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function)  [assignment]
+ pandas/core/indexes/datetimes.py:1385: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function)  [assignment]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standard library _operator module is poorly typed

1 participant