8000 Print incorrect tz argument in error message by oscargus · Pull Request #25420 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Print incorrect tz argument in error message #25420

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 1 commit into from
Mar 9, 2023

Conversation

oscargus
Copy link
Member
@oscargus oscargus commented Mar 9, 2023

PR Summary

Related to #25419.

It would have been slightly easier to realize that something surprising was going on if one could have seen the incorrectly passed tz argument (which was not the one that a user would expect that they had just passed...).

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

@tacaswell tacaswell added this to the v3.8.0 milestone Mar 9, 2023
@ksunden
Copy link
Member
ksunden commented Mar 9, 2023

Anyone can merge post CI

@@ -230,7 +230,7 @@ def _get_tzinfo(tz=None):
return tzinfo
if isinstance(tz, datetime.tzinfo):
return tz
raise TypeError("tz must be string or tzinfo subclass.")
raise TypeError(f"tz must be string or tzinfo subclass, not {tz!r}.")
8000 Copy link
Member

Choose a reason for hiding this comment

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

I think this is good, but perhaps more fundamentally is that dates.py does not define allowable units...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, there seems to be a bit of "abuse" of things. This line doesn't really look like one would hope for:

To me it seems like one is patching dates to, sort of, work with units. But then I have very limited insights into how the units do work.

There can for sure be better fixes for this, but this one the one I could add to at least improve the situation slightly...

My interpretation of the problem is that there is no checking for validity when setting the units. Then, when setting timezone through axis_date, whatever is set as self.units of the Axis is used and an AutoDateLocator is instantiated with that as tz...

@oscargus oscargus merged commit 3810c29 into matplotlib:main Mar 9, 2023
@oscargus oscargus deleted the printincorrecttz branch March 9, 2023 22:32
@valeriupredoi
Copy link

great, very many thanks @oscargus and co! Can probably close #25419 now, but I'll let that up to you guys 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0