Skip to content

Missing type hints for matplotlib.dates.DateFormatter #29994

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
johnthagen opened this issue May 1, 2025 · 2 comments
Open

Missing type hints for matplotlib.dates.DateFormatter #29994

johnthagen opened this issue May 1, 2025 · 2 comments

Comments

@johnthagen
Copy link
Contributor

johnthagen commented May 1, 2025

Using this code:

from matplotlib.dates import DateFormatter

date_fmt = "%H:%M:%S"
date_formatter = DateFormatter(date_fmt)

Running Mypy in strict mode results in an erorr:

$ mypy --strict main.py 
main.py:4: error: Call to untyped function "DateFormatter" in typed context  [no-untyped-call]
Found 1 error in 1 file (checked 1 source file)

We'd run Mypy in strict mode across all of our code base to catch programming errors and would like to use it with matplotlib without the need to suppress errors like this.

Environment

  • Python 3.11.11
  • matplotlib 3.10.1
  • mypy 1.15.0

Related References

@johnthagen
Copy link
Contributor Author

This looks to be the constructor that is missing type annotations

def __init__(self, fmt, tz=None, *, usetex=None):

@oscargus
Copy link
Member

oscargus commented May 1, 2025

The dates module is currently completely untyped. Matplotlib uses stub-files, .pyiin case you or someone else wants to start adding type information.

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

2 participants