Skip to content

fix: Fix and add flake8 to CI #86

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 28 commits into from
Jul 1, 2020
Merged

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Oct 20, 2018

Fixes #49
Fixes #89

Checklist

  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the [Contribution Guide] and my PR follows them.
  • I updated my branch with the master branch.
  • I have added tests that prove my fix is effective or that my feature works
  • [n/a] I have added necessary documentation about the functionality in the appropriate .md file
  • [n/a] I have added in line documentation to the code I modified

Short description of what this PR does:

  • Run flake8 (=pyflakes for bugs and pycodestyle for PEP 8 and style) on the CI to enforce compliance
  • Fix code to pass flake8
  • flake8 doesn't support Python 2.6 (just drop it: Drop support for EOL Python 2.6 #83)
  • Fix a typo in the test_lisence.py filename
  • Make test_license.py use the unittest class for consistency
  • In tests, use Python's 'or', not '||'
  • Replaces and closes stalled chore: Follows PEP8 standard #50.

There some overlap between test_license_year in test/test_license.py and test_license_year in test/__init__.py. Should they be merged somehow?

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Oct 20, 2018
@codecov
Copy link

codecov bot commented Oct 20, 2018

Codecov Report

Merging #86 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #86   +/-   ##
=======================================
  Coverage   99.32%   99.32%           
=======================================
  Files           2        2           
  Lines         149      149           
=======================================
  Hits          148      148           
  Misses          1        1           
Impacted Files Coverage Δ
smtpapi/__init__.py 98.71% <ø> (ø)
test/__init__.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 b3e29d5...0075307. Read the comment docs.

"Copyright (c) 2012-%s SendGrid, Inc."
% datetime.datetime.now().year,
copyright_line,
)
Copy link

Choose a reason for hiding this comment

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

Even this test seems to have the closing bracket consistent (on a separate line) unlike above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do the maintainers think about running Black on the codebase?

https://github.com/ambv/black

Copy link

Choose a reason for hiding this comment

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

@hugovk

Using black is a great idea and sendgrid would only have to send out a fraction of the t-shirts after all the overlapping PEP8 pull requests were closed haha


# ./docker-compose.yml or ./docker/docker-compose.yml
def test_docker_compose(self):
self.assertEqual(True, os.path.isfile('./docker-compose.yml') || os.path.isfile('./docker/docker-compose.yml'))
self.assertEqual(
Copy link

Choose a reason for hiding this comment

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

Couldn't you close #90 if you also used assertTrue's for these again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could do, thought it might help with reviewing to have a single PR #90 to address the single issue #89.

Copy link

Choose a reason for hiding this comment

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

@hugovk

Your logic doesn't quite make sense here. I understand you are trying to send as many pull requests as possible but, if anything, this PR has the advantage of taking care of the long lines which #90 doesn't. If you simply fixed changed them all to assertTrue, this PR would be superior to #90

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Smaller PRs are definitely easier to review and are much less prone to merge conflicts (as this PR has right now, as has some other recent big PRs), and I'm not bothered if #90 is closed without merging :)

I've changed all of assertEqual(True, x) to assertTrue(x) here.

Copy link

Choose a reason for hiding this comment

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

@hugovk

Your logic doesn't make sense, you have essentially a duplicate PR that you refuse to close... why?

@@ -2,47 +2,56 @@
from __future__ import absolute_import, division, print_function

import time
from os import path, sys
Copy link

Choose a reason for hiding this comment

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

I'll admit a personal preference towards using import os in this particular case but the real question is consistency. You don't seem to modify these imports in the other files this PR touches, why only here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will check the remaining comments later, thanks for the reviews!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably only moved imports in this file as flake8 only complained about these ones.

Copy link

Choose a reason for hiding this comment

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

@hugovk

So, why not fix it to be consistent with everything else?

Choose a reason for hiding this comment

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

I don't disagree with the sentiment of having consistency. But the acceptance criteria for #49 is simply that everything passes PEP8. So let's focus on that piece here, and then if folks like, other PRs can be opened to improve the consistency.

@@ -6,7 +6,10 @@

dir_path = os.path.abspath(os.path.dirname(__file__))
readme = io.open(os.path.join(dir_path, 'README.rst'), encoding='utf-8').read()
version = io.open(os.path.join(dir_path, 'VERSION.txt'), encoding='utf-8').read().strip()
version = io.open(
os.path.join(dir_path, 'VERSION.txt'),
Copy link

Choose a reason for hiding this comment

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

As above, no modification of import os. Again, I personally prefer it this way and it seems like having consistency throughout the repo would be better overall.

@@ -7,14 +7,17 @@
if os.path.isfile(os.path.join(dir_path, 'VERSION.txt')):
Copy link

Choose a reason for hiding this comment

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

Another file, another import os instead of from os import path.

@@ -67,14 +70,14 @@ def set_sections(self, value):

def add_send_each_at(self, time):
if 'send_each_at' not in self.data:
self.data['send_each_at'] = []
self.data['send_each_at'] = []
self.data['send_each_at'].append(time)
Copy link

Choose a reason for hiding this comment

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

This function seems like a perfect candidate to change to EAFP over LBYL. Maybe a bit out of scope for this particular PR though but there could be enough of these for a separate PR altogether that could help put you in the top leaderboard spot!

    def add_send_each_at(self, time):
        try:
            self.data['send_each_at'].append(time)
        except KeyError:
            self.data['send_each_at'] = [time]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think that would belong in another PR but I'll leave that for someone else to do.

@@ -128,7 +129,8 @@ def test_repository_files_exists(self):
self.assertTrue(
any(os.path.exists(f) for f in file_path),
msg=self.file_not_found_message.format(
'" or "'.join(file_path)),
'" or "'.join(file_path)
),
Copy link

Choose a reason for hiding this comment

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

Is the trailing comma really necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but in general, if another parameter was added (in practice, not likely with assertTrue), it would mean this previous line wouldn't be included in the diff. Happy to remove it if needed.

This is something Black could sort out automatically :)

Copy link

Choose a reason for hiding this comment

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

As I said before, using black would get rid of a bunch of overlapping PRs in sendgrid's repos.

@hugovk hugovk force-pushed the flake8 branch 3 times, most recently from 85000c1 to c762be6 Compare October 28, 2018 17:53
@hugovk
Copy link
Contributor Author

hugovk commented Oct 28, 2018

Rebased on master to resolve merge conflicts.

@42B
Copy link

42B commented Oct 28, 2018

@hugovk

Why haven't you closed #90 yet? This PR has the same changes included plus it seems to have the advantage of breaking up those longer lines.

@hugovk
Copy link
Contributor Author

hugovk commented Oct 28, 2018

See #86 (comment).

@42B
Copy link

42B commented Oct 28, 2018

@hugovk

If your comment was actually true that you think smaller PRs are better (hard to argue!), why would you make the same changes in this PR which make it bigger? Wouldn't that mean you would have to revert the changes in this PR to make it smaller?

@misterdorm
Copy link

I'm closing #90, and let's go forward with getting #86 reviewed and merged.

@misterdorm misterdorm added difficulty: hard fix is hard in difficulty difficulty: medium fix is medium in difficulty and removed status: code review request requesting a community code review or review from Twilio difficulty: hard fix is hard in difficulty labels Oct 31, 2018
@misterdorm misterdorm mentioned this pull request Oct 31, 2018
6 tasks
Copy link

@misterdorm misterdorm left a comment

Choose a reason for hiding this comment

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

@hugovk Please remove the trailing commas referenced by @42B and me. Any other changes for consistency, etc., I think should be addressed in separate PRs. Please feel free to raise issues against this repo to address those things.

@@ -2,47 +2,56 @@
from __future__ import absolute_import, division, print_function

import time
from os import path, sys

Choose a reason for hiding this comment

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

I don't disagree with the sentiment of having consistency. But the acceptance criteria for #49 is simply that everything passes PEP8. So let's focus on that piece here, and then if folks like, other PRs can be opened to improve the consistency.

@misterdorm misterdorm added the type: community enhancement feature request not on Twilio's roadmap label Oct 31, 2018
@hugovk
Copy link
Contributor Author

hugovk commented Oct 31, 2018

Trailing commas removed!

@hugovk
Copy link
Contributor Author

hugovk commented Aug 7, 2019

Hello, is there anything extra I can do for this PR? Thanks!

@hugovk
Copy link
Contributor Author

hugovk commented Sep 29, 2019

It's nearly time for the next Hacktoberfest! This PR has been approved, is anything else needed to merge it? Thanks!

@hugovk hugovk closed this Nov 16, 2019
@hugovk
Copy link
Contributor Author

hugovk commented Nov 16, 2019

Closing these year-old PRs. Let me know if you're still interested and I can re-open. Thanks!

@childish-sambino childish-sambino changed the title Fix and add flake8 to CI fix: Fix and add flake8 to CI Jul 1, 2020
@childish-sambino childish-sambino merged commit 3666d43 into sendgrid:master Jul 1, 2020
@hugovk hugovk deleted the flake8 branch July 2, 2020 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: work in progress Twilio or the community is in the process of implementing type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid syntax Make smtpapi-python follow PEP8 standards
5 participants