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

RM-17-fix-flake-8-violations #182

Merged
merged 38 commits into from
Dec 17, 2022
Merged

Conversation

ryantimjohn
Copy link
Contributor

Fix Flake8 violations to make future development easier

@ryantimjohn
Copy link
Contributor Author

@Brunope @bcastro-bl I've merged the changes from the other two PRs #180 and #181 in here so that we can merge this one once those other two are in

@ryantimjohn ryantimjohn marked this pull request as ready for review December 16, 2022 13:26
@ryantimjohn ryantimjohn requested a review from Brunope December 16, 2022 13:26
@ryantimjohn
Copy link
Contributor Author

These are all the "low lift" flake violations. The other ones are of the "{foo} is too complex" sort which I feel like can be handled in another PR.

@@ -83,7 +83,7 @@ def set_grant_permissions_for_users(self, schema_name: str, table: str,
def supports_time_type(self) -> bool:
return True

def type_for_date_plus_time(self, has_tz: bool=False) -> sqlalchemy.sql.sqltypes.DateTime:
def type_for_date_plus_time(self, has_tz: bool = False) -> sqlalchemy.sql.sqltypes.DateTime:
Copy link
Collaborator

Choose a reason for hiding this comment

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

From what I've seen so far the original codebase more commonly uses the first option, with no extra space (my personal preference as well), but not a big deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed stylistically but triggering flake8 so 🤷

@@ -15,7 +15,7 @@ def prep_and_load(tbl: TargetTableDetails,
load: Callable[[DBDriver], Optional[int]],
load_exception_type: Type[Exception],
reset_before_reload: Callable[[], None] = lambda: None) -> MoveResult:
logger.info(f"Connecting to database...")
logger.info("Connecting to database...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

prefer single quotes maybe?

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've never gotten a good call on which to use and don't care much but... preserving the formatting here and also this resource recommends that, generally, use doubles for sentences because you might add a contraction, i.e. "You've got an error!" and bork your single quotes 🤷 :
https://docs.ckan.org/en/ckan-2.1.5/python-coding-standards.html#use-single-quotes

@@ -104,7 +104,7 @@ def _get_service(self) -> SheetsService:
def as_json_serializable(self, cell: Any) -> Any:
if isinstance(cell, np.generic):
# MyPy complains that this method does not exist
native = np.asscalar(cell) # type: ignore
native = cell.item()
Copy link
Collaborator

Choose a reason for hiding this comment

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

can't add this comment at the exact line but it seems like there should be a way to use numpy.ndarray.tobytes or something similar to serialize this instead of the nested list comprehension calling this method down below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

definitely agree; this is actually just a change I pulled forward from the RM-7-update-default-python-image-for-integration-tests-to-3-9-remove-build-tests-for-deprecated-python-version branch where there were so many errors on transition that I was trying to keep changes as minimal as possible.

But, if you're willing to dive deep and rewrite this call, just create a ticket for it and it'll be a good way to get to know the tool better! We'll fix the failing tests first but then the world is our oyster. =)

@@ -1 +1 @@
166
9
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't exactly understand how these are used but why is this such a large numerical change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So these "high water marks" are the number of violations there were of a particular protocol. In this case, we had 166 Flake8 violations and brought them down to 9. I mostly did this through using autopep8 then hand correcting some of the other errors. We still have 9 flake8 errors remaining... but those are from "too high complexity" which is more than I wanted to take on in a single PR.

Copy link
Collaborator

@Brunope Brunope left a comment

Choose a reason for hiding this comment

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

I don't exactly understand the flake8 water mark change but other than that looks good to me.

@ryantimjohn ryantimjohn merged commit 12aa7bd into master Dec 17, 2022
@ryantimjohn ryantimjohn deleted the RM-17-fix-flake-8-violations branch December 17, 2022 10:48
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