Skip to content

[MNT] Typing: Use Literal for set_loglevel #30301

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

Closed

Conversation

nrnavaneet
Copy link
Contributor

@nrnavaneet nrnavaneet commented Jul 12, 2025

This PR addresses part of #30257 by improving type safety and IDE support for set_loglevel.

Changes in this PR:

  • Introduced LogLevel as a TypeAlias in matplotlib.typing, using Literal to restrict accepted values.
  • Updated set_loglevel() in init.py to use LogLevel.

This improves discoverability and static type checking for valid logging levels like "info", "debug", "error", etc.

Related work not included here
MarkerType updates were implemented by @ZPyrolink in #30261
Event type literals for connect methods were contributed by @ZPyrolink in #30275

`Added type hints for LogLevel, RcGroupType, and RcParamKeyType in matplotlib/typing.py`

`Updated type hints for set_loglevel, rc, and rcParams in matplotlib
nrnavaneet and others added 2 commits July 13, 2025 04:03
…amKeyType`

`Remove tools/update_rcparam_typing.py script`

`Update matplotlib rc function to accept string group instead of RcGroupType`

`Remove unused imports and docstrings`
@nrnavaneet nrnavaneet changed the title [MNT] Add Literal type hints for rc, set_loglevel, and RcParams keys [MNT] Typing: Use Literal for set_loglevel Jul 12, 2025
@nrnavaneet
Copy link
Contributor Author

Hi @timhoffm
I’m still learning and fairly new to contributing. I initially tried addressing all three parts of the issue but ran into a few problems. So I’ve decided to focus on fixing one part at a time to keep things clean and manageable.
Please let me know if anything needs adjusting. I really appreciate the guidance

@nrnavaneet nrnavaneet force-pushed the fix/use-literal-typing-v2 branch from d6b7a49 to 92b69f7 Compare July 12, 2025 22:55
@nrnavaneet
Copy link
Contributor Author

Hi, I wanted to clarify an issue I’m currently facing.

As part of the initial changes, I had created a temporary script tools/update_rcparam_typing.py to help with regenerating the RcParamKeyType block. I’ve since removed the file from the project, but it still appears in the PR history as both added and deleted, causing the CI check to fail.

I’ve tried resolving it, but I haven’t been able to fix it successfully. I’d really appreciate any guidance on how to clean this up properly, should I rebase and drop that commit, or is there a preferred approach for this situation?

Thanks so much for your patience and support!

@nrnavaneet nrnavaneet closed this Jul 12, 2025
@nrnavaneet nrnavaneet deleted the fix/use-literal-typing-v2 branch July 12, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy