Skip to content

Fixing pep8 issues #65

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 23 commits into from
May 22, 2018
Merged

Fixing pep8 issues #65

merged 23 commits into from
May 22, 2018

Conversation

jlindenger
Copy link
Contributor

@jlindenger jlindenger commented Oct 30, 2017

Fixes #64

Description of the change: I knocked out some quick fixes for your PEP8 issues. There's actually a few more in there than the ones you linked from CodeClimate as well because I just ran flake8 locally using your tox.ini file.

Reason for the change: Conforming to standards for #64

@SendGridDX
Copy link

SendGridDX commented Oct 30, 2017

CLA assistant check
All committers have signed the CLA.

@jlindenger
Copy link
Contributor Author

I'm not sure what I did that caused some of the older commits to show up here since they were already in master. Any idea?

@Madhur96
Copy link
Contributor

Did you try to squash your commits ?

).encode('utf-8')
params = (kwargs['query_params']
if 'query_params' in kwargs
else None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, is there any reason not to just use a regular if/else here?

if 'query_params' in kwargs:
    params = kwargs['query_params']
else:
    params = None

Or maybe just an if?

params = None
if 'query_params' in kwargs:
    params = kwargs['query_params']

url = self._build_versioned_url(url) if self._version else self.host + url
url = (self._build_versioned_url(url)
if self._version
else self.host + url)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the reason someone would use ternary over a regular if/else is that it can fit on one line. In this case, the line exceeds the PEP8 recommendation and now it is back to being multi-line... shouldn't this go back to being a regular if/else?

if self._version:
    url = self._build_versioned_url(url)
else:
    url = self.host + url

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You make an excellent point. This is why friends don't let friends edit ternary operators in the middle of the night... Will fix. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

@jlindenger ,

haha no problem!

register.py Outdated

output = pypandoc.convert('README.md', 'rst')
f = open('README.txt','w+')
f = open('README.txt', 'w+')
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this use a with statement (also for consistency since with is also used 12 lines below)?

with open('README.txt', 'w+') as f:
    f.write(output)

register.py Outdated
replacement = '|SendGrid Logo|\n\n.. |SendGrid Logo| image:: https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png\n :target: https://www.sendgrid.com'
final_text = readme_rst.replace(replace,replacement)
replace = ('[SendGrid Logo]\n'
'(https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)')
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this what multi-line strings are for?

replace = """\
[SendGrid Logo]
(https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)"""

setup.py Outdated
@@ -6,12 +6,14 @@
if os.path.exists('README.txt'):
long_description = open('README.txt').read()


def getRequires():
Copy link
Contributor

Choose a reason for hiding this comment

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

PEP8 == snake_case function names

def get_requires():

register.py Outdated
replacement = ('|SendGrid Logo|\n\n'
'.. |SendGrid Logo| image:: '
'https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png\n'
' :target: https://www.sendgrid.com')
Copy link
Contributor

Choose a reason for hiding this comment

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

Too bad a multi-line string couldn't be used quite as well here since the url makes that one line 87 chars long (but no newline characters or extra brackets):

replacement = """\
|SendGrid Logo|

.. |SendGrid Logo| image:: https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png
   :target: https://www.sendgrid.com"""

Copy link
Contributor Author

@jlindenger jlindenger Oct 31, 2017

Choose a reason for hiding this comment

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

I put a backslash in the multi-line comment to shorten the line. Maybe not the cleanest thing in the world, but I think it works better than the first attempt. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jlindenger ,

Ah of course! Nice one.

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Nov 1, 2017
@thinkingserious
Copy link
Contributor

@jlindenger

We can’t merge your PR without the CLA being signed.

[ ] Sign the CLA before November 3rd
[ ] Tag @mbernier and @thinkingserious to let us know it is signed

Then we will comment with a link to get your shirt!

@jlindenger
Copy link
Contributor Author

@mbernier @thinkingserious CLA should be good now. Apparently I had one commit that snuck in with my work email, so I needed to fix that. The conflict is probably something that you should resolve right before you merge (just taking out the unused imports in test_unit.py). I think the underlying file is too much of a moving target to keep pulling in and fixing before a merge.

@thinkingserious
Copy link
Contributor

Awesome, thanks @jlindenger! If you have not already, you can redeem your swag here. Thanks!

@thinkingserious thinkingserious added the difficulty: medium fix is medium in difficulty label Feb 27, 2018
@thinkingserious thinkingserious added the type: twilio enhancement feature request on Twilio's roadmap label Feb 27, 2018
@codecov
Copy link

codecov bot commented May 22, 2018

Codecov Report

Merging #65 into master will decrease coverage by 0.05%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #65      +/-   ##
==========================================
- Coverage   92.22%   92.17%   -0.06%     
==========================================
  Files           6        6              
  Lines         296      294       -2     
==========================================
- Hits          273      271       -2     
  Misses         23       23
Impacted Files Coverage Δ
tests/test_unit.py 99.21% <100%> (-0.02%) ⬇️
python_http_client/__init__.py 100% <100%> (ø) ⬆️
python_http_client/client.py 79.2% <66.66%> (ø) ⬆️

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 70797c3...6aced08. Read the comment docs.

@thinkingserious thinkingserious merged commit 6aced08 into sendgrid:master May 22, 2018
@thinkingserious
Copy link
Contributor

Hello @jlindenger,

Thanks again for the PR!

We appreciate your contribution and look forward to continued collaboration. Thanks!

Team SendGrid DX

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: code review request requesting a community code review or review from Twilio type: twilio enhancement feature request on Twilio's roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make this repo conform to PEP8 standards
8 participants