pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/pull/31428

obal-0bd78641c0a1f3e0.css" /> Relax type hints for xy and xytext in annotate by dikshajangra12918-oss · Pull Request #31428 · matplotlib/matplotlib · GitHub
Skip to content

Relax type hints for xy and xytext in annotate#31428

Open
dikshajangra12918-oss wants to merge 2 commits intomatplotlib:mainfrom
dikshajangra12918-oss:patch-1
Open

Relax type hints for xy and xytext in annotate#31428
dikshajangra12918-oss wants to merge 2 commits intomatplotlib:mainfrom
dikshajangra12918-oss:patch-1

Conversation

@dikshajangra12918-oss
Copy link
Copy Markdown

PR SUMMARY

The current type hints for 'xy' and 'xytext' in 'Axes.annotate' are too strict ('tuple[float, float]') compared to the flexibility supported at runtime.

In practice, Matplotlib accepts a wider range of inputs (example, dates, array-like objects, or other coordinate representations). Restricting these parameters to fixed float tuples can lead to incorrect type checking.

This change relaxes the type hints to 'Any' to better reflect the actual behaviour of the API.

WHY IS THIS CHANGE NECESSARY?

The existing type hints do not accurately represent the accepted input types, which can cause confusion for users and issues with static type checkers.

WHAT DOES THIS SOLVE?

It aligns the type hints with real usage, improving developer experience and reducing false type errors.

ADDITIONAL NOTES

This change only updates type hints and does not affect runtime behaviour.

The current type hints for xy and xytext are too strict (tuple[float, float]) compared to the actual flexibility supported at runtime (example, dates, etc).
This change relaxes the type hints to better reflect real usage.
@melissawm melissawm moved this to Needs review in First Time Contributors Mar 31, 2026
@melissawm melissawm moved this from Needs review to Waiting for author in First Time Contributors Mar 31, 2026
@melissawm melissawm added the status: autoclose candidate PRs that are not yet ready for review and may be automatically closed in two weeks label Mar 31, 2026
@github-actions
Copy link
Copy Markdown

⏰ This pull request might be automatically closed in two weeks from now.

Thank you for your contribution to Matplotlib and for the effort you have put into this PR. This pull request does not yet meet the quality and clarity standards needed for an effective review. Project maintainers have limited time for code reviews, and our goal is to prioritize well-prepared contributions to keep Matplotlib maintainable.

Matplotlib maintainers cannot provide one-to-one guidance on this PR. However, if you ask focused, well-researched questions, a community member may be willing to help. 💬

To increase the chance of a productive review:

As the author, you are responsible for driving this PR, which entails doing necessary background research as well as presenting its context and your thought process. If you are a new contributor, or do not know how to fulfill these requirements, we recommend that you familiarize yourself with Matplotlib's development conventions or engage with the community via our Discourse or one of our meetings before submitting code.

If you substantially improve this PR within two weeks, leave a comment and a team member may remove the status: autoclose candidate label and the PR stays open. Cosmetic changes or incomplete fixes will not be sufficient. Maintainers will assess improvements on their own schedule. Please do not ping (@) maintainers.

@timhoffm timhoffm linked an issue Mar 31, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

We have not yet decided in #30365 whether we want to generalize to Any but if so, this should only be the coordinate components.

Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
@dikshajangra12918-oss
Copy link
Copy Markdown
Author

Thanks for the suggestion!

@timhoffm
Copy link
Copy Markdown
Member

timhoffm commented Apr 1, 2026

Please run boilerplate.py as suggested in the failing tests.

@dikshajangra12918-oss
Copy link
Copy Markdown
Author

Sir, after applying 'tuple[Any, Any]' , I'm seeing multiple test failures.

Instead of this, should we use a more constrained union type(e.g., including numeric and converter-supported types)?

@dikshajangra12918-oss
Copy link
Copy Markdown
Author

Please run boilerplate.py as suggested in the failing tests.

Sir, I’ve been trying to run the "boilerplate.py" file for the past hour, but I’m not able to get a proper working solution. I tried several methods like creating a virtual environment, installing all required dependencies, setting "PYTHONPATH", and reinstalling matplotlib, but I’m still facing errors.

It seems that the script requires a proper development build of matplotlib, and I’m unable to set that up correctly on my system.

Could you please guide me on what exactly I should do next?

@jklymak
Copy link
Copy Markdown
Member

jklymak commented Apr 1, 2026

It seems that the script requires a proper development build of matplotlib, and I’m unable to set that up correctly on my system.

Could you please guide me on what exactly I should do next?

You will have to get a proper development version built. Please ask questions at discourse.matplotlib.org

Copy link
Copy Markdown
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Need to get pyplot changes in...

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

Labels

first-contribution status: autoclose candidate PRs that are not yet ready for review and may be automatically closed in two weeks

Projects

Status: Waiting for author

Development

Successfully merging this pull request may close these issues.

[Bug]: Type hints for xy and xycoords in annotate are too strict

4 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

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