Skip to content

Clean up mypy & ruff config #30258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 5, 2025
Merged

Clean up mypy & ruff config #30258

merged 4 commits into from
Jul 5, 2025

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jul 4, 2025

PR summary

Drop outdated options, and exceptions that are no longer needed because the files were fixed. Also, fix a few simpler cases so that more exceptions can be dropped.

PR checklist

@github-actions github-actions bot added GUI: webagg Documentation: examples files in galleries/examples Documentation: tutorials files in galleries/tutorials labels Jul 4, 2025
HourLocator, MicrosecondLocator, MinuteLocator,
MonthLocator, RRuleLocator, SecondLocator,
WeekdayLocator, YearLocator, rrulewrapper)
from matplotlib.dates import DateFormatter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that while these aren't referenced in the code directly, they are referenced from strings that get evaled:

        Traceback (most recent call last):
          File "/home/circleci/project/galleries/examples/ticks/date_formatters_locators.py", line 58, in <module>
            plot_axis(ax, locator, xmax, fmt)
          File "/home/circleci/project/galleries/examples/ticks/date_formatters_locators.py", line 27, in plot_axis
            ax.xaxis.set_major_locator(eval(locator))
                                       ^^^^^^^^^^^^^
          File "<string>", line 1, in <module>
        NameError: name 'AutoDateLocator' is not defined

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I'll add a comment to make that more obvious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh, isort wants to remove the noqa, while ruff/flake8 wants it. I'll just restore the exception then.

QuLogic added 3 commits July 4, 2025 14:46
ruff uses `project.requires-python`, so the ruff-only `target-version`
is not needed.

Other exceptions can be dropped since they are all clear of warnings.
The removed excludes are covered by the first line. The Unpack feature
was enabled by default in 1.9, which is our minimum.
@QuLogic QuLogic force-pushed the ruff-update branch 2 times, most recently from cf7c0d5 to 77deb26 Compare July 4, 2025 18:50
These examples only needed a single fix to remove the exception.
@timhoffm timhoffm merged commit faa3670 into matplotlib:main Jul 5, 2025
49 of 50 checks passed
@QuLogic QuLogic deleted the ruff-update branch July 6, 2025 00:31
@QuLogic QuLogic added this to the v3.11.0 milestone Jul 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: examples files in galleries/examples Documentation: tutorials files in galleries/tutorials GUI: webagg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants