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

Added Error Checking For Empty Granularity List #1016

Merged
merged 8 commits into from
Oct 24, 2021
Merged

Conversation

anishnya
Copy link
Member

@anishnya anishnya commented Aug 7, 2021

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

Closes #1015. Added a basic error check to make sure empty granularity list raises a Value Error.

@codecov
Copy link

codecov bot commented Aug 7, 2021

Codecov Report

Merging #1016 (b35df3d) into master (f7a3aa3) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1016   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         2221      2223    +2     
  Branches       349       350    +1     
=========================================
+ Hits          2221      2223    +2     
Impacted Files Coverage Δ
arrow/arrow.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 f7a3aa3...b35df3d. Read the comment docs.

arrow/arrow.py Outdated
if not granularity:
raise ValueError(
"Empty granularity list provided. "
"Please select between 'second', 'minute', 'hour', 'day', 'week', 'month' or 'year'."
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second sentence should be reworded since this is a list. It's currently phrased as if only one choice can be made.

arrow/arrow.py Outdated Show resolved Hide resolved
Co-authored-by: Chris <30196510+systemcatch@users.noreply.github.com>
Copy link
Member

@jadchaar jadchaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment

arrow/arrow.py Outdated
if not granularity:
raise ValueError(
"Empty granularity list provided. "
"Please select one or more from ['second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year']."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better to write this as a plain english list rather than as a list. We should probably just join the member variable like we do here:

arrow/arrow/arrow.py

Lines 1026 to 1029 in 2ade710

supported_attr = ", ".join(self._ATTRS_PLURAL + additional_attrs)
raise ValueError(
f"Invalid shift time frame. Please select one of the following: {supported_attr}."
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I concur with this. Makes it easier to digest as an error.

@anishnya anishnya requested a review from jadchaar August 29, 2021 21:33
Copy link
Member

@krisfremen krisfremen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor change to make it more dynamic, so we can get rid of the hardcoded strings.

arrow/arrow.py Show resolved Hide resolved
@systemcatch
Copy link
Collaborator

Do we want to get this in 1.2.0?

@systemcatch
Copy link
Collaborator

@jadchaar worth adding this into the 1.2.0 release?

@jadchaar
Copy link
Member

@jadchaar worth adding this into the 1.2.0 release?

Sure let me get it up to date with master and add it to 1.2.1.

Copy link
Member

@jadchaar jadchaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jadchaar jadchaar merged commit cc1cbeb into master Oct 24, 2021
@jadchaar jadchaar deleted the 1015_bug_fix branch October 24, 2021 21:56
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.

Empty List of Granularities For Humanize Doesn't Raise Value Error
5 participants