Skip to content
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

parser(fix): more robust (UTC prefix in TzInfoParser #1165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kroozo
Copy link

@kroozo kroozo commented Oct 2, 2023

Pull Request Checklist

Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:

  • 🧪 Added tests for changed code.
  • 🛠️ All tests pass when run locally (run tox or make test to find out!).
  • 🧹 All linting checks pass when run locally (run tox -e lint or make lint to find out!).
  • 📚 Updated documentation for changed code.
  • ⏩ Code is up-to-date with the master branch.

If you have any questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!

Description of Changes

The changes introduced in this PR comes with unintended side effects:
It removed the end of string matching from the regex to allow for the arbitrary information at the end of the string. The intention was to match time zones like this: "(UTC+01:00) Amsterdam, Berlin, Bern, Rom, Stockholm, Wien"

This however applied to input without the "(UTC" prefix, so things like: +01:00.23 would also be handled by the code, and silently treated like "+01:00" which sounds bad. Also, misformats like this :"(UTC+01:00 Amsterdam, Berlin, Bern, Rom, Stockholm, Wien" would silently pass

The updated regex takes this into consideration, makes the closing parenthesis mandatory, and will not allow postfixes unless the string starts with the UTC prefix in parenthesis.

Notes

While this PR keeeps the original intention working, note that such timezone declarations are not valid in ISO (as far as I can tell without buying the standard :)), so it's a bit misleading.

Also, after treating the special cases here the work is basically dumped to dateutil's tz, which also seem to do some strange stuff. It'll return a tzstr for monstorities like "(UTC+01:00 Amsterdam whatver else even if it is very long as long as you dont have a comma", which probably shouln't be like that, but I really did not want to stir that much into a codebase where I don't get the intentions, so for now it behaves the same way it did before these 2 PRs , but it probably could be made better :)

We've been using this to make sure user input is valid TZ, so it's a bit of a bummer.

@codecov
Copy link

codecov bot commented Oct 8, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (87a1a77) 100.00% compared to head (edf6f2a) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1165   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         2326      2326           
  Branches       400       400           
=========================================
  Hits          2326      2326           
Files Coverage Δ
arrow/parser.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant