-
Notifications
You must be signed in to change notification settings - Fork 52
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #86 +/- ##
=======================================
Coverage 99.32% 99.32%
=======================================
Files 2 2
Lines 149 149
=======================================
Hits 148 148
Misses 1 1
Continue to review full report at Codecov.
|
test/test_license.py
Outdated
"Copyright (c) 2012-%s SendGrid, Inc." | ||
% datetime.datetime.now().year, | ||
copyright_line, | ||
) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
test/test_project.py
Outdated
|
||
# ./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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, why not fix it to be consistent with everything else?
There was a problem hiding this comment.
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'), |
There was a problem hiding this comment.
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.
smtpapi/__init__.py
Outdated
@@ -7,14 +7,17 @@ | |||
if os.path.isfile(os.path.join(dir_path, 'VERSION.txt')): |
There was a problem hiding this comment.
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
.
smtpapi/__init__.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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) | |||
), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
85000c1
to
c762be6
Compare
Rebased on master to resolve merge conflicts. |
See #86 (comment). |
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -2,47 +2,56 @@ | |||
from __future__ import absolute_import, division, print_function | |||
|
|||
import time | |||
from os import path, sys |
There was a problem hiding this comment.
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.
Trailing commas removed! |
Hello, is there anything extra I can do for this PR? Thanks! |
It's nearly time for the next Hacktoberfest! This PR has been approved, is anything else needed to merge it? Thanks! |
Closing these year-old PRs. Let me know if you're still interested and I can re-open. Thanks! |
Fixes #49
Fixes #89
Checklist
Short description of what this PR does:
flake8
(=pyflakes
for bugs andpycodestyle
for PEP 8 and style) on the CI to enforce complianceflake8
flake8
doesn't support Python 2.6 (just drop it: Drop support for EOL Python 2.6 #83)unittest
class for consistencyThere some overlap between
test_license_year
intest/test_license.py
andtest_license_year
intest/__init__.py
. Should they be merged somehow?