-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
bpo-40536: Add zoneinfo.available_timezones #20158
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
This was not specified in the PEP, but it will likely be a frequently requested feature if it's not included.
|
@FFY00 Do you mind reviewing this version? @pablogsal was going to do it, but something came up. |
Lib/test/test_zoneinfo/_support.py
Outdated
| if not modname.startswith("tzdata"): | ||
| continue | ||
|
|
||
| if len(modname) > 6 and modname[7] != ".": | ||
| continue |
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.
modname[7] != "."Did you mean modname[6]?
>>> modname = 'tzdata.something'
>>> modname[7]
's'
>>> modname[6]
'.'And just a nitpick, but maybe
if modname.split('.', maxsplit=1)[0] != 'tzdata':
continueThere 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.
Good call, I like your version much better. Thanks!
| for zone in f: | ||
| zone = zone.strip() | ||
| if zone: | ||
| valid_zones.add(zone) |
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.
I am not sure if it's better, but it could be replaced with
valid_zones.update(filter(None, map(str.strip, f)))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.
I personally like using these more functional constructs like maps and filters, but I don't think this will make it appreciably faster (probably a little, but I'm guessing it won't shave off more than a few µs) and I think most people would find it harder to read and understand the filter-map version.
Also, for debugging reasons, it's nice when the different actions are all separate lines.
I think if this were a smaller function I'd probably go with your version.
Lib/test/test_zoneinfo/_support.py
Outdated
| if not modname.startswith("tzdata"): | ||
| continue |
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.
This can now be removed since modname.split(".", 1)[0] != "tzdata" also handles it.
FFY00
left a comment
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.
LGTM :)
|
Ok, I'm going to merge this so it will be ready for the beta. I'll leave it as a "release blocker" and if @ambv thinks we should revert for 3.9 we'll push it to 3.10. |
|
|
It's hard to tell, but I think the buildbot failure is flakiness unrelated to this change; the zoneinfo tests are passing. The build after it succeeded, so I don't think there's anything to worry about. |
|
This is a known issue. You are hitting https://bugs.python.org/issue40500. |
This was not specified in the PEP, but it will likely be a frequently requested feature if it's not included. This includes only the "canonical" zones, not a simple listing of every valid value of `key` that can be passed to `Zoneinfo`, because it seems likely that that's what people will want.
This was not specified in the PEP, but it will likely be a frequently requested feature if it's not included.
@ambv Given the uncertainty about the stability of this feature (we didn't have a lot of time to design it and it ends up being slightly a more complicated UI problem than one would think), please let me know ASAP if you'd like to exclude this from the beta period and push it to 3.10.
https://bugs.python.org/issue40536