-
-
Notifications
You must be signed in to change notification settings - Fork 682
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
Update shift() for issue #1145 #1194
Conversation
added check_imaginary parameter to the function
@@ -492,7 +492,7 @@ def range( | |||
|
|||
values = [getattr(current, f) for f in cls._ATTRS] | |||
current = cls(*values, tzinfo=tzinfo).shift( # type: ignore[misc] | |||
**{frame_relative: relative_steps} | |||
check_imaginary=True, **{frame_relative: relative_steps} |
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.
Mind explaining why we want to force usage of check imaginary here rather than making it an argument?
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.
To bypass unnecessary checks when performance matters and they know they won't encounter DST transitions.
The default behavior of check_imaginary=True ensures that users get correct and valid results by default. If a user deliberately wants to skip the check for performance reasons or because they're confident it isn't needed, they can do so by setting the parameter to False.
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.
Ah my bad, I now see that this was added as true in range and dehumanize shift usages to maintain backwards compatibility right?
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.
Yes exactly
@jadchaar If all the requirements are met, can you please approve 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.
LGTM
Could you please add a Hacktoberfest accepted label to this, will be helpful |
Pull Request Checklist
Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:
tox
ormake test
to find out!).tox -e lint
ormake lint
to find out!).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
Added check_imaginary parameter to the function referring to the issue #1145
block is only executed if check_imaginary is True. If set to False, this check is skipped for improved performance when DST changes are not a concern.
Benefits: