arrow-py / arrow

🏹 Better dates & times for Python
https://arrow.readthedocs.io
Apache License 2.0
8.71k stars 673 forks source link

Fix multiple bugs in arrow.get() tzinfo kwarg handling #968

Closed systemcatch closed 3 years ago

systemcatch commented 3 years ago

Pull Request Checklist

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

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 tzinfo kwarg should now be handled correctly rather than being dropped.

fixes #944

codecov[bot] commented 3 years ago

Codecov Report

Merging #968 (4d65c00) into master (fe1aaae) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #968   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         2036      2036           
  Branches       328       328           
=========================================
  Hits          2036      2036           
Impacted Files Coverage Δ
arrow/factory.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update fe1aaae...4d65c00. Read the comment docs.

jadchaar commented 3 years ago

LGTM, but I think this is a more widespread issue @systemcatch. We should be passing along the tz object in all of these other factory methods as well: https://github.com/arrow-py/arrow/blob/08705bcde7a8eef65a40f43acd733863d8c1f63b/arrow/factory.py#L234-L247 (and maybe more!). Weird this has not come up until now, but we may need to apply this change to a bunch of factory methods. Thoughts?

systemcatch commented 3 years ago

Hey @jadchaar I agree with you on the Arrow one to avoid this bug below.

>>> arw=arrow.Arrow(2021, 4, 29, 22, 7, tzinfo="America/Chicago")
>>> arw
<Arrow [2021-04-29T22:07:00-05:00]>
>>> arrow.get(arw, tzinfo="Europe/London")
<Arrow [2021-04-29T22:07:00-05:00]>

However the date factory doesn't need it I think and all the others seem correct.

jadchaar commented 3 years ago

@systemcatch I made a few tweaks to comments and made the tzinfo kwarg explicit for the get() factory method in 4d65c00eb3f0b5f9a5ef29b5495980d6514c6154. Let me know what you think!

systemcatch commented 3 years ago

Looks good to me Jad, feel free to merge if you're happy with everything.