Skip to content

[MNT]: mark **kwargs as Any to suppress warnings about "partially unknown" function signatures in pyright #27030

Closed as not planned

Description

@vidhanio

Summary

It would be nice if all the **kwargs in functions were explicitly marked with Any to suppress unknown errors from pyright/pylance in strict mode.

image

Proposed fix

replace untyped **kwargs with **kwargs: Any in function signatures.

Activity

  1. ksunden commented on Oct 9, 2023

    @ksunden
    Member

    I have no issue with doing this, especially if it helps with pyright (I mostly use mypy which doesn't complain about this)

    My slight hesitation is a readability argument, where it doesn't add any information, but just takes up more space. However, these are (largely) isolated in pyi stub files (plus generated code in pyplot.py), where any readability argument really falls quite flat.

    Longer term I'd be interested in investigating PEP 692 style TypedDict annotations for more of our **kwargs, but I suspect that will prove a bit frustrating because:

    • The sheer number of arguments some of our methods/classes have
    • The fact that things seem reusable, but then you have to take out certain arguments in various usages
    • That it requires keeping a parallel list up to date (in addition to the source (usually __init__ kwargs) and the docstring(s) (though we template that out pretty well in most cases)), having to update the TypedDict definition adds complexity there

    We do use such for some deprecation machinery already, but that is the only place we use it so far:

    https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/_api/deprecation.pyi#L15

    @vidhanio would you like to open a PR for this?

  2. PaMeirelles commented on Oct 11, 2023

    @PaMeirelles

    Hi! If no one opposes, I would like to claim this issue. I would love to contribute to matplotlib, and this issue seems simple enough to be a good starting point. Please let me know if there are any objections. Thanks!

  3. rcomer commented on Oct 11, 2023

    @rcomer
    Member

    @PaMeirelles anyone can work on any issue so please go ahead! Our Contributors’ Guide is here:
    https://matplotlib.org/devdocs/devel/index.html

  4. PaMeirelles commented on Oct 13, 2023

    @PaMeirelles

    Awesome! Thanks for the opportunity.

  5. vidhanio commented on Oct 13, 2023

    @vidhanio
    Author

    sorry for the inactivity, it's midterm season 😅 thank you @PaMeirelles! if you'd like to open a draft PR or something of the sort, i would be happy to help with your effort.

  6. timhoffm commented on Dec 19, 2025

    @timhoffm
    Member

    Closing as inactive. Feel free to reopen if there’s still need.

  7. added a commit that references this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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