Skip to content

Allow None in set_prop_cycle (in type hints) #29920

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 2 commits into from
Apr 17, 2025
Merged

Conversation

vnmabus
Copy link
Contributor

@vnmabus vnmabus commented Apr 15, 2025

PR summary

set_prop_cycle allows to pass None for resetting the cycle, but with the current type hints, type checkers give an error for this case.

PR checklist

`set_prop_cycle` allows to pass `None` for resetting the cycle, but with the current type hints, type checkers give an error for this case.
@vnmabus vnmabus changed the title Allow None in set_prop_cycle Allow None in set_prop_cycle (in type hints) Apr 15, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@QuLogic
Copy link
Member

QuLogic commented Apr 16, 2025

Can you also fix the docstring for set_prop_cycle? It has a type of only ~.cycler.Cycler (and should get or None as well), which is probably where this type hint came from. (Though it does mention None in the description.)

Add `None` to the docstring as a request from the maintainers.
@vnmabus
Copy link
Contributor Author

vnmabus commented Apr 16, 2025

Can you also fix the docstring for set_prop_cycle? It has a type of only ~.cycler.Cycler (and should get or None as well), which is probably where this type hint came from. (Though it does mention None in the description.)

I just did that. Maybe in the future it would make sense to add the types directly to the code (instead of using stubs) and remove the types from the docstrings, because these are not checked and can be easily out of sync with the actual types. Sphinx can add the types to the generated docs if you do it that way, and if you want to preserve the current presentation format maybe that can be done through a Sphinx plugin. What is the official stance of Matplotlib on this?

@QuLogic QuLogic added this to the v3.10.2 milestone Apr 17, 2025
@timhoffm timhoffm merged commit f017a0e into matplotlib:main Apr 17, 2025
41 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Apr 17, 2025
@timhoffm
Copy link
Member

When introducing typing, we decided to go with type stubs for several reasons. I would not say that this is set in stone forever, but there are currently no plans to change it.

@ksunden ksunden mentioned this pull request May 9, 2025
5 tasks
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.

3 participants