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

Update pep8 to pycodestyle #5867

Merged
merged 1 commit into from May 24, 2018

Conversation

Projects
None yet
5 participants
@cheister
Copy link
Contributor

cheister commented May 24, 2018

Problem

The pep8 project was moved to pycodestyle https://pypi.org/project/pycodestyle/

Solution

Update pep8 to pycodestyle

Result

Most of the checks should be the same.

Release Notes for pycodestyle from https://github.com/PyCQA/pycodestyle/blob/master/CHANGES.txt

2.4.0 (2018-04-10)
------------------

New checks:

* Add W504 warning for checking that a break doesn't happen after a binary
  operator. This check is ignored by default. PR #502.
* Add W605 warning for invalid escape sequences in string literals. PR #676.
* Add W606 warning for 'async' and 'await' reserved keywords being introduced
  in Python 3.7. PR #684.
* Add E252 error for missing whitespace around equal sign in type annotated
  function arguments with defaults values. PR #717.

Changes:

* An internal bisect search has replaced a linear search in order to improve
  efficiency. PR #648.
* pycodestyle now uses PyPI trove classifiers in order to document supported
  python versions on PyPI. PR #654.
* 'setup.cfg' '[wheel]' section has been renamed to '[bdist_wheel]', as
  the former is legacy. PR #653.
* pycodestyle now handles very long lines much more efficiently for python
  3.2+. Fixes #643. PR #644.
* You can now write 'pycodestyle.StyleGuide(verbose=True)' instead of
  'pycodestyle.StyleGuide(verbose=True, paths=['-v'])' in order to achieve
  verbosity. PR #663.
* The distribution of pycodestyle now includes the license text in order to
  comply with open source licenses which require this. PR #694.
* 'maximum_line_length' now ignores shebang ('#!') lines. PR #736.
* Add configuration option for the allowed number of blank lines. It is
  implemented as a top level dictionary which can be easily overwritten. Fixes
  #732. PR #733.

Bugs:

* Prevent a 'DeprecationWarning', and a 'SyntaxError' in future python, caused
  by an invalid escape sequence. PR #625.
* Correctly report E501 when the first line of a docstring is too long.
  Resolves #622. PR #630.
* Support variable annotation when variable start by a keyword, such as class
  variable type annotations in python 3.6. PR #640.
* pycodestyle internals have been changed in order to allow 'python3 -m
  cProfile' to report correct metrics. PR #647.
* Fix a spelling mistake in the description of E722. PR #697.
* 'pycodestyle --diff' now does not break if your 'gitconfig' enables
  'mnemonicprefix'. PR #706.

2.3.1 (2017-01-31)
------------------

Bugs:

* Fix regression in detection of E302 and E306; #618, #620

2.3.0 (2017-01-30)
------------------

New Checks:

* Add E722 warning for bare ``except`` clauses
* Report E704 for async function definitions (``async def``)

Bugs:

* Fix another E305 false positive for variables beginning with "class" or
  "def"
* Fix detection of multiple spaces between ``async`` and ``def``
* Fix handling of variable annotations. Stop reporting E701 on Python 3.6 for
  variable annotations.

2.2.0 (2016-11-14)
------------------

Announcements:

* Added Make target to obtain proper tarball file permissions; #599

Bugs:

* Fixed E305 regression caused by #400; #593

2.1.0 (2016-11-04)
------------------

Announcements:

* Change all references to the pep8 project to say pycodestyle; #530

Changes:

* Report E302 for blank lines before an "async def"; #556
* Update our list of tested and supported Python versions which are 2.6, 2.7,
  3.2, 3.3, 3.4 and 3.5 as well as the nightly Python build and PyPy.
* Report E742 and E743 for functions and classes badly named 'l', 'O', or 'I'.
* Report E741 on 'global' and 'nonlocal' statements, as well as prohibited
  single-letter variables.
* Deprecated use of `[pep8]` section name in favor of `[pycodestyle]`; #591
* Report E722 when bare except clause is used; #579

Bugs:

* Fix opt_type AssertionError when using Flake8 2.6.2 and pycodestyle; #561
* Require two blank lines after toplevel def, class; #536
* Remove accidentally quadratic computation based on the number of colons. This
  will make pycodestyle faster in some cases; #314

2.0.0 (2016-05-31)
------------------

Announcements:

* Repository renamed to `pycodestyle`; Issue #466 / #481.
* Added joint Code of Conduct as member of PyCQA; #483

Changes:

* Added tox test support for Python 3.5 and pypy3
* Added check E275 for whitespace on `from ... import ...` lines; #489 / #491
* Added W503 to the list of codes ignored by default ignore list; #498
* Removed use of project level `.pep8` configuration file; #364

Bugs:

* Fixed bug with treating `~` operator as binary; #383 / #384
* Identify binary operators as unary; #484 / #485

1.7.0 (2016-01-12)
------------------

Announcements:

* Repository moved to PyCQA Organization on GitHub:
  https://github.com/pycqa/pep8

Changes:

* Reverted the fix in #368, "options passed on command line are only ones
  accepted" feature. This has many unintended consequences in pep8 and flake8
  and needs to be reworked when I have more time.
* Added support for Python 3.5. (Issue #420 & #459)
* Added support for multi-line config_file option parsing. (Issue #429)
* Improved parameter parsing. (Issues #420 & #456)

Bugs:

* Fixed BytesWarning on Python 3. (Issue #459)

@cheister cheister requested a review from stuhood May 24, 2018

@kwlzn
Copy link
Member

kwlzn left a comment

lgtm overall, but I think the options scope change will be a blocker.

class PEP8Subsystem(PluginSubsystemBase):
options_scope = 'pycheck-pep8'
class PyCodeStyleSubsystem(PluginSubsystemBase):
options_scope = 'pycheck-pycodestyle'

This comment has been minimized.

@kwlzn

kwlzn May 24, 2018

Member

this options scope change is going to break consumers (their options flags and pants.ini would have to change as a result) and would be disallowed under the current deprecation policy here: https://www.pantsbuild.org/deprecation_policy.html#disallowed-api-changes

I think you'll have to deprecate the old scope and alias it to the new one to avoid that (or can just leave this existing scope name untouched).

This comment has been minimized.

@benjyw

benjyw May 24, 2018

Contributor

You can deprecate an entire scope using deprecated_options_scope and deprecated_options_scope_removal_version, which will read options from both the new and old scope, but issue a deprecation warning in the latter case.

See, e.g., https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/jvm/subsystems/scala_platform.py#L44

This comment has been minimized.

@cheister

cheister May 24, 2018

Contributor

Nice. I added

deprecated_options_scope = 'pycheck-pep8'
deprecated_options_scope_removal_version = '1.9.0.dev0'

This comment has been minimized.

@stuhood

stuhood May 24, 2018

Member

We're currently in 1.8.0.dev0, so it would be good to target 1.10.0.dev0 with this. Thanks!

This comment has been minimized.

@cheister

cheister May 24, 2018

Contributor

Updated to 1.10.0.dev0


def get_plugin_type(self):
from pants.contrib.python.checks.tasks.checkstyle.pep8 import PEP8Checker
return PEP8Checker
from pants.contrib.python.checks.tasks.checkstyle.pycodestyle import PyCodeStyleChecker

This comment has been minimized.

@kwlzn

kwlzn May 24, 2018

Member

would it make sense to move this import to the top of the file while you're in here?

This comment has been minimized.

@cheister

cheister May 24, 2018

Contributor

It looks like the late import is done for get_plugin_type in every other *_subsystem.py in contrib/python/src/python/pants/contrib/python/checks/tasks/checkstyle also. I'm not sure why. Maybe move all of them in another commit?

This comment has been minimized.

@benjyw

benjyw May 25, 2018

Contributor

Please don't. These are imported late for performance reasons IIRC.

@stuhood stuhood requested review from benjyw and CMLivingston and removed request for stuhood May 24, 2018

@CMLivingston
Copy link
Contributor

CMLivingston left a comment

LGTM, mod the details of the scope deprecation. For me, deprecation + aliasing is preferable.

@cheister cheister force-pushed the cheister:update-pep8-to-pycodestyle branch from 3e54028 to 4cc31d0 May 24, 2018

@kwlzn

kwlzn approved these changes May 24, 2018

Copy link
Member

kwlzn left a comment

lgtm

Chris Heisterkamp

@cheister cheister force-pushed the cheister:update-pep8-to-pycodestyle branch from 4cc31d0 to 753c2ca May 24, 2018

@cheister cheister merged commit 7ba55f7 into pantsbuild:master May 24, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@cheister cheister deleted the cheister:update-pep8-to-pycodestyle branch May 24, 2018

@stuhood

This comment has been minimized.

Copy link
Member

stuhood commented May 29, 2018

@cheister : It looks like changing the name of the subsystem changed how to refer-to/disable checks in the --lint-pythonstyle-suppress file. Do you have time to add a deprecated check for the old name?

@cheister

This comment has been minimized.

Copy link
Contributor

cheister commented May 31, 2018

@stuhood How about this? #5888

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment