Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug/TYP]: misc type errors #26858

Open
Open
@twoertwein

Description

@twoertwein

Bug summary

Pandas uses mypy/pyright to check its internal code. We currently pin matplotlib <3.8 to avoid many type errorspandas-dev/pandas#55210 Many of these errors are definitely on pandas's side :) but a few might be bugs in matplotlib.

Code for reproduction

# Simplified examples from pandas that trigger type errorsdefformat_date_labels(ax:Axes,rot)->None:forlabelinax.get_xticklabels():label.set_ha("right")# error: "Text" has no attribute "set_ha"  [attr-defined]deftest(cellText:np.ndarray):# error: Argument "cellText" to "table" has incompatible type "ndarray[Any, Any]"; expected "Sequence[Sequence[str]] | None"  [arg-type]# maybe use a Protocol such as Iterable?matplotlib.table.table(ax,cellText=cellText**kwargs)defdecorate_axes(ax:Axes,freq,kwargs)->None:# The following might just be bad pandas code# error: "Axes" has no attribute "freq"  [attr-defined]ax.freq=freqxaxis=ax.get_xaxis()xaxis.freq=freqifnothasattr(ax,"legendlabels"):ax.legendlabels= [kwargs.get("label",None)]else:ax.legendlabels.append(kwargs.get("label",None))# error: Argument 1 to "FixedLocator" has incompatible type "ndarray[Any, Any]"; expected "Sequence[float]"  [arg-type]FixedLocator(ax.get_xticks())# same also for set_ylabel, maybe use a protocol for str-coercible types instead of requiring strdeftest(ax:Axes,label:Hashable):# Hashable might be too wide, but str seems to strictax.set_xlabel(label)deftest(ax:Axes):axes=np.array([ax])# error: Argument 1 to "set_ticks_props" has incompatible type "ndarray[Any, dtype[Any]]"; expected "Axes | Sequence[Axes]"  [arg-type]set_ticks_props(axes,**kwargs)

Actual outcome

the above type errors

Expected outcome

Fewer errors, but still some errors - some of the pandas code is definitely to be blamed!

Additional information

No response

Operating system

No response

Matplotlib Version

3.8

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp