-
Notifications
You must be signed in to change notification settings - Fork 523
Warn on unidentified tz #540
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
Conversation
|
Broadly speaking I'm in favor of this, but I'll note that the behavior of Maybe some sort of |
|
I haven't given any thought to the strptime implications. For the moment I'm planning to focus on the two errors this turned up.
Do you mean an option that allows users to restore the current behavior? |
It really has no implications for
Yes, though I wasn't thinking of a keyword argument. Maybe it's too abstruse, but I was thinking of something roughly like this (this is for the case that def tzinfoswrapper(tzinfos, drop_missing=True):
return tzinfos.get if drop_missing else tzinfosThat will return a |
|
Just changed raise to a warning per brief discussion in #541. |
| def jump(self, name): | ||
| return name.lower() in self._jump | ||
|
|
||
| def weekday(self, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should raise a specific warning type so that it can be easily ignored by people who don't want to see this message. I suggest subclassing maybe RuntimeWarning, maybe UnknownTimezoneWarning(RuntimeWarning)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I wouldn't specify ValueError in the message. Just say it will raise an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I wouldn't specify
ValueErrorin the message. Just say it will raise an error.
But the error (in the future) will be a ValueError (or a subclass), so the users seeing it can already prepare for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wagner-certat It might be a ValueError, but probably it will be a subclass. I'm not quite sure how they would "prepare for it" using just the information that it might raise a ValueError, though, since that would catch nearly all the errors raised by parse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I also catch all ValueErrors already now.
dateutil/test/test_parser.py
Outdated
| def testRandomFormat26(self): | ||
| self.assertEqual(parse("5:50 A.M. on June 13, 1990"), | ||
| datetime(1990, 6, 13, 5, 50)) | ||
| with pytest.warns(UserWarning, match="identified but not understood"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I guess I didn't notice this in the first round of review. This is one of those xfail-ish tests I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah, I think this is part of what motivated the PR about checking for 1-character timezones more carefully (and from there discussion about keeping "A.M." in one piece in timelex.split...). Hopefully we'll be able to get rid of this line before long.
|
@jbrockmendel Is this still WIP or is it ready to merge? |
I haven't implemented the suggestion to make a specific subclass |
|
@jbrockmendel I'll wait for now, but if it gets close to release time (which should be soon-ish) if it's not done I'll just add that myself. |
|
@jbrockmendel At this point we're just blocking on this, #613 and #571 for the 2.7.0 release. I think I might push #571 to 2.7.1 just to get this ridiculous number of changes out the door. Like I said, I can make the required changes right before merge, but just pinging in case you've forgotten about this one. |
|
This has fallen off my radar screen, will likely stay that way for a while longer. I'll make a note to circle back Feb 1, but feel free to run with it if that's too long a wait. |
|
@jbrockmendel Planning on cutting a release today, do you want to review my changes? |
|
I'll take a look. |
edit warning per suggestion
|
OK, this is the last blocker, so as soon as the rebased version passes CI I'm going to merge. |
|
LGTM |
|
While #575 is possibly in development, are there any plans to add the |
|
@Harmon758 Your comment made me realize that there actually isn't a good way to get the old behavior, so I've opened #661 as a first pass. The warning is a specific warning class so that it should be easy to filter out if you don't care about it, so for now filtering out the behavior is the way to get the old behavior. There will be a clear way to opt in to the old behavior before the final switch happens. |
Current incorrect behavior:
This PR raises instead of silently dropping this timezone information.
This surfaces two test failures that look like false-positives slipped through and got assigned to res.tzname. Thats the "WIP" part of the PR.