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

chore: Make pylintrc ignore fewer rules and pylintrc more readable #2522

Merged
merged 11 commits into from
Jan 7, 2021

Conversation

aahung
Copy link
Contributor

@aahung aahung commented Jan 6, 2021

Which issue(s) does this change fix?

Why is this change necessary?

This brings back some pylint improvements which were originally implemented in #2375 and reverted in #2400 to make room for a massive merge.

How does it address the issue?

What side effects does this change have?

Checklist

  • Add input/output type hints to new functions/methods
  • Write design document (Do I need to write a design document?)
  • Write unit tests
  • Write/update functional tests
  • Write/update integration tests
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@aahung aahung requested review from sriram-mv, hoffa and elbayaaa January 6, 2021 21:42
@aahung aahung changed the title chore: Make pylintrc ignore rule and pylintrc more readable chore: Make pylintrc ignore fewer rules and pylintrc more readable Jan 7, 2021
Copy link
Contributor

@hoffa hoffa left a comment

Choose a reason for hiding this comment

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

A lot of these changes seem to be about pylint enforcing a draconian line length limit. black on the other hand already partially enforces this, but in a more pragmatic manner ("an inherently long URL is long, so it's okay"). I wonder if it might be better to turn of the length enforcement and delegate that to black?

@@ -41,7 +41,7 @@ def handle_parse_result(self, ctx, opts, args):
if mutex_opt in opts:
req_cnt -= 1

if req_cnt == 0:
if not req_cnt:
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it complain about this? It's weird using boolean logic on integers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In pylint's source

Most of the times you should use the fact that integers with a value of 0 are false.
An exception to this rule is when 0 is allowed in the program and has a
different meaning than None!

https://github.com/PyCQA/pylint/blob/master/pylint/extensions/comparetozero.py#L23

SAM_PUBLISH_DOC = "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-publishing-applications.html" # noqa
SAM_PACKAGE_DOC = "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-package.html" # noqa
SAM_DOC_PREFIX = "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide"
SAM_PUBLISH_DOC = f"{SAM_DOC_PREFIX}/serverless-sam-template-publishing-applications.html" # noqa
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the error here? Doesn't noqa prevent the complaints? Feels more of a fix to deal with pylints whims.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a fix. I will remove # noqa here instead of reverting in this case because making the common prefix into a variable does make it easier to maintain

# Only sleep if there have been no retry_attempts
time.sleep(self.client_sleep if retry_attempts == 0 else 0)
time.sleep(0 if retry_attempts else self.client_sleep)
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the complaint here? As above, not sure why it prefers boolean logic on integers.

@aahung
Copy link
Contributor Author

aahung commented Jan 7, 2021

black on the other hand already partially enforces this, but in a more pragmatic manner ("an inherently long URL is long, so it's okay").

black does nothing about strings, it won't split long string like this, either make a super long comment line shorter.
image

But I do agree we should make URLs exceptions

@aahung
Copy link
Contributor Author

aahung commented Jan 7, 2021

I reverted the changes that split URLs into multiple lines. It made copy/paste difficult. For all other splitting-the-line scenarios, I think they are pretty legit and I don't have a good reason not to do them.

Copy link
Contributor

@hoffa hoffa left a comment

Choose a reason for hiding this comment

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

Looking great! Thank you! 🙌

@aahung aahung merged commit c3578c7 into aws:develop Jan 7, 2021
mndeveci pushed a commit to mndeveci/aws-sam-cli that referenced this pull request Jan 19, 2021
…ws#2522)

* chore: Make pylintrc ignore rule more readable

* chore: Remove pylint rules that do not apply for python 3

* chore: Enable pylint rule Unused import

* chore: Enable pylint multi-processes

* chore: Enable pylint line too long

* chore: Remove unnecessary pylint disable

* chore: Enable pylint Else If Used checker

* chore: Enable pylint compare to zero/empty string
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