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

Fixes #2828 - Changes from pep8 to pycodestyle #2829

Merged
merged 7 commits into from
Apr 4, 2019

Conversation

karlcow
Copy link
Member

@karlcow karlcow commented Mar 28, 2019

This PR fixes issue #2828

Proposed PR background

pep8 has changed name and is deprecated. We need to switch to pycodestyle (new name for pep8). This created a version bump with a couple of things to fix, choose.

This adjusts the

  • circleci configuration
  • the code itself
  • The documentation

The tests are running on my local computer.

The biggest change in the code is probably
cba1193

that I have singled out. The rest is following basically the recommendation of pycodestyle.
It will also make it possible to test the code on #2825 project, where circleci requires pycodestyle #2825 (comment)

r? @miketaylr

karlcow added 7 commits March 28, 2019 09:53
The project has been renamed and pycodestyle is the new version.
It will also means a bump into the checking that will need to be fixed.

We will do that in the subsequent commits.
This is the new keyword for removing the check for a specific line.
This was initially triggered by pycodestyle W504. It kinds of force you to choose your style in between W503 and W504. Breaking before binary operators or after.

To avoid it altogether, I switched to ''.join() which is more effective anyway in performance.
https://wiki.python.org/moin/PythonSpeed/PerformanceTips#String_Concatenation
We will ignore W504 for most of the cases.
Basically pycostyle forces you to choose in between W504 or W503
@karlcow karlcow requested a review from miketaylr March 28, 2019 01:49
@@ -414,7 +414,7 @@ def extract_url(issue_body):
URL in webcompat.com bugs follow this pattern:
**URL**: https://example.com/foobar
"""
url_pattern = re.compile('\*\*URL\*\*\: (.+)\n')
url_pattern = re.compile(r'\*\*URL\*\*\: (.+)')
Copy link
Member Author

Choose a reason for hiding this comment

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

just explaining here the why. This was W605 invalid escape sequence ‘x’
The explanation is https://lintlyci.github.io/Flake8Rules/rules/W605.html

https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and treat backslashes as literal characters. As a result, in string literals, '\U' and '\u' escapes in raw strings are not treated specially. Given that Python 2.x’s raw unicode literals behave differently than Python 3.x’s the 'ur' syntax is not supported.

"report-uri /csp-report"
)
]
response.headers['Content-Security-Policy'] = (''.join(csp_params))
Copy link
Member Author

Choose a reason for hiding this comment

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

I was not forced to do that as I chose to ignore W504, but this is more performant. So this is a win-win change.

@karlcow
Copy link
Member Author

karlcow commented Apr 4, 2019

@miketaylr could we merge this?

Copy link
Member

@miketaylr miketaylr left a comment

Choose a reason for hiding this comment

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

oops, sorry for the delay.

@miketaylr miketaylr merged commit 022ee4c into webcompat:master Apr 4, 2019
@karlcow karlcow deleted the 2828/1 branch May 9, 2019 07:43
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.

2 participants