8000 [Bug]: Missing typing for dates.py · Issue #26942 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

[Bug]: Missing typing for dates.py #26942

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

Open
chacabuco opened this issue Sep 28, 2023 · 1 comment
Open

[Bug]: Missing typing for dates.py #26942

chacabuco opened this issue Sep 28, 2023 · 1 comment

Comments

@chacabuco
Copy link

Bug summary

with mypy, MinuteLocator results in error:

error: Call to untyped function "MinuteLocator" in typed context [no-untyped-call]

Code for reproduction

import matplotlib.dates as mdates

mdates.MinuteLocator(byminute=range(0, 60, 5))
# run mypy --strict

Actual outcome

error: Call to untyped function "MinuteLocator" in typed context [no-untyped-call]

Expected outcome

No Mypy error

Additional information

No response

Operating system

Ubuntu

Matplotlib Version

3.8.0

Matplotlib Backend

QTAgg

Python version

3.8.10

Jupyter version

No response

Installation

pip

@ksunden
Copy link
Member
ksunden commented Sep 28, 2023

Units handling is a second portion which was omitted from the first round of type hinting.

While much of it should be relatively straightforward (at the very least formatters/locators/etc, as in this example) the units portions of the code have quite a bit of dynamic behavior that is not always possible to capture in a static typing context.

We can (and should) do better where we are able, but addressing units as a whole is a relatively large typing task.

Similar to #26941, the base class for Locators is type hinted, and so some level of benefit from type hints can be gained by using that, but it does not address the constructor call.

In general I think that --strict is often too strict especially when it comes to the no-untyped-call check

I would perhaps suggest adding a config for matplotlib to ignore this rule:

https://mypy.readthedocs.io/en/stable/config_file.html#example-mypy-ini

https://mypy.readthedocs.io/en/stable/config_file.html#example-pyproject-toml

[[tool.mypy.overrides]]
module = "matplotlib"
disallow_untyped_calls = false

because while I would welcome improving our type hints, there may well continue to be portions that are not type hinted.

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

No branches or pull requests

3 participants
0