aeye-lab / pymovements

A python package for processing eye movement data
https://pymovements.readthedocs.io
MIT License
57 stars 11 forks source link

unexpected mypy error in matplotlib functions in plotting #560

Closed dkrako closed 9 months ago

dkrako commented 9 months ago

Current Behavior

mypy fails since today. It has to do something with matplotlib type definitions, maybe there was an update?

Expected Behavior

There should be no new mypy errors on this untouched code.

Minimum acceptance criteria

Failure Logs

src/pymovements/plotting/traceplot.py:169: error: Argument "segmentdata" to "LinearSegmentedColormap" has incompatible type "dict[str, list[list[float]]]"; expected "dict[Literal['red', 'green', 'blue', 'alpha'], Sequence[tuple[float, ...]]]"  [arg-type]
src/pymovements/plotting/traceplot.py:178: error: Argument "vmin" to "Normalize" has incompatible type "Union[floating[_64Bit], Any]"; expected "Optional[float]"  [arg-type]
src/pymovements/plotting/traceplot.py:186: error: Module has no attribute "_scale_mapping"  [attr-defined]
src/pymovements/plotting/traceplot.py:221: error: Argument 1 to "set_title" of "Axes" has incompatible type "Optional[str]"; expected "str"  [arg-type]
src/pymovements/plotting/main_sequence_plot.py:113: error: Argument 7 to "scatter" has incompatible type "**dict[str, Collection]"; expected "Union[Sequence[Union[Union[tuple[float, float, float], str], Union[str, tuple[float, float, float, float], tuple[Union[tuple[float, float, float], str], float], tuple[tuple[float, float, float, float], float]]]], Union[Union[tuple[float, float, float], str], Union[str, tuple[float, float, float, float], tuple[Union[tuple[float, float, float], str], float], tuple[tuple[float, float, float, float], float]]], None]"  [arg-type]
src/pymovements/plotting/main_sequence_plot.py:113: error: Argument 7 to "scatter" has incompatible type "**dict[str, Collection]"; expected "Union[str, Colormap, None]"  [arg-type]
src/pymovements/plotting/main_sequence_plot.py:113: error: Argument 7 to "scatter" has incompatible type "**dict[str, Collection]"; expected "Union[str, Normalize, None]"  [arg-type]
src/pymovements/plotting/main_sequence_plot.py:113: error: Argument 7 to "scatter" has incompatible type "**dict[str, Collection]"; expected "Optional[float]"  [arg-type]
src/pymovements/plotting/main_sequence_plot.py:113: error: Argument 7 to "scatter" has incompatible type "**dict[str, Collection]"; expected "Union[float, Sequence[float], None]"  [arg-type]
src/pymovements/plotting/main_sequence_plot.py:113: error: Argument 7 to "scatter" has incompatible type "**dict[str, Collection]"; expected "Union[Union[Union[tuple[float, float, float], str], Union[str, tuple[float, float, float, float], tuple[Union[tuple[float, float, float], str], float], tuple[tuple[float, float, float, float], float]]], Sequence[Union[Union[tuple[float, float, float], str], Union[str, tuple[float, float, float, float], tuple[Union[tuple[float, float, float], str], float], tuple[tuple[float, float, float, float], float]]]], None, Literal['face', 'none']]"  [arg-type]
src/pymovements/plotting/main_sequence_plot.py:113: error: Argument 7 to "scatter" has incompatible type "**dict[str, Collection]"; expected "bool"  [arg-type]
src/pymovements/plotting/main_sequence_plot.py:116: error: Argument 1 to "title" has incompatible type "Optional[str]"; expected "str"  [arg-type]

Steps to Reproduce

rm -rf .tox/mypy  # clean mypy environment
tox -e mypy

Checklist

SiQube commented 9 months ago

I'll fix it, interestingly pre-commit.ci does not fail

SiQube commented 9 months ago

I found the root cause:

https://github.com/matplotlib/matplotlib/releases

matplotlib 3.8 was released which got rid of typestubs and now uses inherent typing (which is different), I'll fix it asap.