Skip to content

Make validation class pass the linter #578

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

Merged
merged 16 commits into from
Dec 3, 2020
Merged

Conversation

sgsmob
Copy link
Contributor

@sgsmob sgsmob commented Nov 24, 2020

Description

Refactor validation module to be lint compliant and otherwise more readable. This PR fails to address one lint issue with the number of member variables of Validator; I will address it in a follow-on PR (see #579).

Changelog

  • Refactor validate() into a short, high-level function
  • Load all data in a separate routine rather than one at a time
  • No longer check input parameters for type or value since the checks would always pass
  • Add tests for functions outside of validate.py

@nmdefries nmdefries self-requested a review November 24, 2020 20:18
nmdefries
nmdefries previously approved these changes Nov 24, 2020
@sgsmob
Copy link
Contributor Author

sgsmob commented Nov 24, 2020

@nmdefries can you unapprove this? I'm going to add some lint compliance fixes and haven't pushed them through.

@nmdefries nmdefries dismissed their stale review November 24, 2020 23:28

Reviewed too early; more changes to come

@sgsmob sgsmob changed the title Remove vestigial checks in validator Make validation class pass the linter Nov 30, 2020
@sgsmob sgsmob requested a review from nmdefries November 30, 2020 18:12
Copy link
Contributor

@nmdefries nmdefries left a comment

Choose a reason for hiding this comment

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

Everything else looks good. Thanks for the improved organization and structure!


if geo_sig_api_df is None:
if isinstance(api_df_or_error, APIDataFetchError):
self.increment_total_checks()
Copy link
Contributor

Choose a reason for hiding this comment

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

increment_total_checks() should be outside of the if statement of the check since we want to count it whether the check passes (if block isn't run) or fails (if block is run).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, fixed.

@@ -31,6 +31,7 @@ def __init__(self, check_data_id, expression, message):
pass a check, provide the date
- message: str explaining why an error was raised
"""
super().__init__(message)
Copy link
Contributor

Choose a reason for hiding this comment

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

The super init changes the output of Validator.exit() so that only the error message is printed. This isn't a concern here since you have the incoming validator report PR; just wanted you to be aware that the goal is to include the check_data_id (unique error-data combo identifier), expression, and message in error output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought I had fixed this by moving the call to super().__init__() to the top of the function, but you are correct that it squashes the full error message. I have changed this to take all the arguments which produces the same output as before.

@sgsmob sgsmob requested a review from nmdefries December 3, 2020 15:45
@krivard krivard merged commit 7fb09b6 into cmu-delphi:main Dec 3, 2020
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.

3 participants