[Python-modules-commits] [pycodestyle] 01/04: Import pycodestyle_2.1.0.orig.tar.gz

Ondřej Nový onovy at moszumanska.debian.org
Tue Nov 8 11:28:19 UTC 2016


This is an automated email from the git hooks/post-receive script.

onovy pushed a commit to branch master
in repository pycodestyle.

commit b6f164577232e0c2fc07336a9f3047071796cfe6
Author: Ondřej Nový <onovy at debian.org>
Date:   Tue Nov 8 10:50:12 2016 +0100

    Import pycodestyle_2.1.0.orig.tar.gz
---
 CHANGES.txt                      |  23 ++++++
 CONTRIBUTING.rst                 |  74 ++++++++++++++++-
 PKG-INFO                         |  59 +++++++++++---
 README.rst                       |  34 +++++---
 dev-requirements.txt             |   1 +
 docs/developer.rst               |  16 +++-
 docs/intro.rst                   |  29 ++++---
 pycodestyle.egg-info/PKG-INFO    |  59 +++++++++++---
 pycodestyle.egg-info/SOURCES.txt |   1 +
 pycodestyle.py                   | 166 +++++++++++++++++++++++++++++++--------
 setup.cfg                        |   2 +-
 testsuite/E10.py                 |   6 +-
 testsuite/E12not.py              |   3 +
 testsuite/E22.py                 |   1 +
 testsuite/E30.py                 |  68 ++++++++++++++++
 testsuite/E30not.py              |  19 +++++
 testsuite/support.py             |   1 +
 testsuite/test_all.py            |   1 +
 testsuite/test_api.py            |   4 +-
 testsuite/test_parser.py         |   8 +-
 testsuite/test_shell.py          |  48 +++++------
 testsuite/utf-8.py               |  17 ----
 22 files changed, 510 insertions(+), 130 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index e129dc8..3eab548 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,29 @@
 Changelog
 =========
 
+2.1.0 (unreleased)
+------------------
+
+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
+
+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)
 ------------------
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 9771176..caab193 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -1,4 +1,72 @@
-Contributing to ``pycodestyle``
-===============================
+Contributing to pycodestyle
+===========================
 
-Please see the `developer notes <https://pycodestyle.readthedocs.io/en/latest/developer.html>`_
+When contributing to pycodestyle, please observe our `Code of Conduct`_.
+
+Step 1: Forking pycodestyle for editing
+---------------------------------------
+
+Fork the pycodestyle repository on GitHub. This will add
+pycodestyle to your GitHub account. You will push your changes to your
+fork and then make pull requests into the official pycodestyle repository.
+
+GitHub has an excellent `guide`_ that has screenshots on how to do this.
+
+Next, clone your fork of the pycodestyle repository to your system for
+editing::
+
+    $ git clone https://www.github.com/<your_username>/pycodestyle
+
+Now you have a copy of the pycodestyle codebase that is almost ready for
+edits.  Next we will setup `virtualenv`_ which will help create an isolated
+environment to manage dependancies.
+
+
+Step 2: Use virtualenv when developing
+--------------------------------------
+
+`virtualenv`_ is a tool to create isolated python environments.
+First, install virtualenv with::
+
+    $ pip install virtualenv
+
+Next, ``cd`` to the pycodestyle repository that you cloned earlier and
+create, then activate a virtualenv::
+
+    $ cd pycodestyle
+    $ virtualenv pycodestyle-venv
+    $ source pycodestyle-venv/bin/activate
+
+Now you can install the pycodestyle requirements::
+
+    $ pip install -r dev-requirements.txt
+
+To deactivate the virtualenv you can type::
+
+    $ deactivate
+
+For more information see `virtualenv`_'s documentation.
+
+
+Step 3: Run tests
+-----------------
+
+Before creating a pull request you should run the tests to make sure that the
+changes that have been made haven't caused any regressions in functionality.
+To run the tests, the core developer team and Travis-CI use `tox`_::
+
+    $ pip install -r dev-requirements.txt
+    $ tox
+
+All the tests should pass for all available interpreters, with the summary of::
+
+    congratulations :)
+
+At this point you can create a pull request back to the official pycodestyles
+repository for review! For more information on how to make a pull request,
+GitHub has an excellent `guide`_.
+
+.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/
+.. _guide: https://guides.github.com/activities/forking/
+.. _tox: https://tox.readthedocs.io/en/latest/
+.. _Code of Conduct: http://meta.pycqa.org/en/latest/code-of-conduct.html
diff --git a/PKG-INFO b/PKG-INFO
index 1f5a696..627b221 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pycodestyle
-Version: 2.0.0
+Version: 2.1.0
 Summary: Python style guide checker
 Home-page: https://pycodestyle.readthedocs.io/
 Author: Ian Lee
@@ -9,6 +9,22 @@ License: Expat license
 Description: pycodestyle (formerly called pep8) - Python style guide checker
         ===============================================================
         
+        .. image:: https://img.shields.io/travis/PyCQA/pycodestyle.svg
+           :target: https://travis-ci.org/PyCQA/pycodestyle
+           :alt: Build status
+        
+        .. image:: https://readthedocs.org/projects/pycodestyle/badge/?version=latest
+            :target: https://pycodestyle.readthedocs.io
+            :alt: Documentation Status
+        
+        .. image:: https://img.shields.io/pypi/wheel/pycodestyle.svg
+           :target: https://pypi.python.org/pypi/pycodestyle
+           :alt: Wheel Status
+        
+        .. image:: https://badges.gitter.im/PyCQA/pycodestyle.svg
+           :alt: Join the chat at https://gitter.im/PyCQA/pycodestyle
+           :target: https://gitter.im/PyCQA/pycodestyle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
+        
         pycodestyle is a tool to check your Python code against some of the style
         conventions in `PEP 8`_.
         
@@ -17,8 +33,12 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
         .. note::
         
             This package used to be called ``pep8`` but was renamed to ``pycodestyle``
-            to reduce confusion. Further discussion `here
-            <https://github.com/PyCQA/pycodestyle/issues/466>`_.
+            to reduce confusion. Further discussion can be found `in the issue where
+            Guido requested this
+            change <https://github.com/PyCQA/pycodestyle/issues/466>`_, or in the
+            lightning talk at PyCon 2016 by @IanLee1521:
+            `slides <https://speakerdeck.com/ianlee1521/pep8-vs-pep-8>`_
+            `video <https://youtu.be/PulzIT8KYLk?t=36m>`_.
         
         Features
         --------
@@ -35,7 +55,7 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
         Installation
         ------------
         
-        You can install, upgrade, uninstall ``pycodestyle.py`` with these commands::
+        You can install, upgrade, and uninstall ``pycodestyle.py`` with these commands::
         
           $ pip install pycodestyle
           $ pip install --upgrade pycodestyle
@@ -91,14 +111,6 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
         Links
         -----
         
-        .. image:: https://api.travis-ci.org/PyCQA/pycodestyle.png?branch=master
-           :target: https://travis-ci.org/PyCQA/pycodestyle
-           :alt: Build status
-        
-        .. image:: https://pypip.in/wheel/pycodestyle/badge.png?branch=master
-           :target: https://pypi.python.org/pypi/pycodestyle
-           :alt: Wheel Status
-        
         * `Read the documentation <https://pycodestyle.readthedocs.io/>`_
         
         * `Fork me on GitHub <http://github.com/PyCQA/pycodestyle>`_
@@ -107,6 +119,29 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
         Changelog
         =========
         
+        2.1.0 (unreleased)
+        ------------------
+        
+        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
+        
+        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)
         ------------------
diff --git a/README.rst b/README.rst
index 466509b..abd51e4 100644
--- a/README.rst
+++ b/README.rst
@@ -1,6 +1,22 @@
 pycodestyle (formerly called pep8) - Python style guide checker
 ===============================================================
 
+.. image:: https://img.shields.io/travis/PyCQA/pycodestyle.svg
+   :target: https://travis-ci.org/PyCQA/pycodestyle
+   :alt: Build status
+
+.. image:: https://readthedocs.org/projects/pycodestyle/badge/?version=latest
+    :target: https://pycodestyle.readthedocs.io
+    :alt: Documentation Status
+
+.. image:: https://img.shields.io/pypi/wheel/pycodestyle.svg
+   :target: https://pypi.python.org/pypi/pycodestyle
+   :alt: Wheel Status
+
+.. image:: https://badges.gitter.im/PyCQA/pycodestyle.svg
+   :alt: Join the chat at https://gitter.im/PyCQA/pycodestyle
+   :target: https://gitter.im/PyCQA/pycodestyle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
+
 pycodestyle is a tool to check your Python code against some of the style
 conventions in `PEP 8`_.
 
@@ -9,8 +25,12 @@ conventions in `PEP 8`_.
 .. note::
 
     This package used to be called ``pep8`` but was renamed to ``pycodestyle``
-    to reduce confusion. Further discussion `here
-    <https://github.com/PyCQA/pycodestyle/issues/466>`_.
+    to reduce confusion. Further discussion can be found `in the issue where
+    Guido requested this
+    change <https://github.com/PyCQA/pycodestyle/issues/466>`_, or in the
+    lightning talk at PyCon 2016 by @IanLee1521:
+    `slides <https://speakerdeck.com/ianlee1521/pep8-vs-pep-8>`_
+    `video <https://youtu.be/PulzIT8KYLk?t=36m>`_.
 
 Features
 --------
@@ -27,7 +47,7 @@ Features
 Installation
 ------------
 
-You can install, upgrade, uninstall ``pycodestyle.py`` with these commands::
+You can install, upgrade, and uninstall ``pycodestyle.py`` with these commands::
 
   $ pip install pycodestyle
   $ pip install --upgrade pycodestyle
@@ -83,14 +103,6 @@ Or you can display how often each error was found::
 Links
 -----
 
-.. image:: https://api.travis-ci.org/PyCQA/pycodestyle.png?branch=master
-   :target: https://travis-ci.org/PyCQA/pycodestyle
-   :alt: Build status
-
-.. image:: https://pypip.in/wheel/pycodestyle/badge.png?branch=master
-   :target: https://pypi.python.org/pypi/pycodestyle
-   :alt: Wheel Status
-
 * `Read the documentation <https://pycodestyle.readthedocs.io/>`_
 
 * `Fork me on GitHub <http://github.com/PyCQA/pycodestyle>`_
diff --git a/dev-requirements.txt b/dev-requirements.txt
new file mode 100644
index 0000000..053148f
--- /dev/null
+++ b/dev-requirements.txt
@@ -0,0 +1 @@
+tox
diff --git a/docs/developer.rst b/docs/developer.rst
index 3acf2a6..db36538 100644
--- a/docs/developer.rst
+++ b/docs/developer.rst
@@ -14,8 +14,8 @@ conditions of the :ref:`Expat license <license>`.  Fork away!
 * `Source code <https://github.com/pycqa/pycodestyle>`_ and
   `issue tracker <https://github.com/pycqa/pycodestyle/issues>`_ on GitHub.
 * `Continuous tests <http://travis-ci.org/pycqa/pycodestyle>`_ against Python
-  2.6 through 3.4 and PyPy, on `Travis-CI platform
-  <http://about.travis-ci.org/>`_.
+  2.6 through 3.5 as well as the nightly Python build and PyPy, on `Travis-CI
+  platform <https://docs.travis-ci.com//>`_.
 
 .. _available on GitHub: https://github.com/pycqa/pycodestyle
 
@@ -27,7 +27,8 @@ Some high-level aims and directions to bear in mind for contributions:
 
 * ``pycodestyle`` is intended to be as fast as possible.
   Using the ``ast`` module defeats that purpose.
-  The `pep8-naming <https://github.com/flintwork/pep8-naming>`_ plugin exists for this sort of functionality.
+  The `pep8-naming <https://github.com/flintwork/pep8-naming>`_ plugin exists
+  for this sort of functionality.
 * If you want to provide extensibility / plugins,
   please see `flake8 <https://gitlab.com/pycqa/flake8>`_ -
   ``pycodestyle`` doesn't want or need a plugin architecture.
@@ -103,6 +104,15 @@ Then be sure to pass the tests::
 
 When contributing to pycodestyle, please observe our `Code of Conduct`_.
 
+To run the tests, the core developer team and Travis-CI use tox::
+
+    $ pip install -r dev-requirements.txt
+    $ tox
+
+All the tests should pass for all available interpreters, with the summary of::
+
+    congratulations :)
+
 .. _PEP 8: http://www.python.org/dev/peps/pep-0008/
 .. _Code of Conduct: http://meta.pycqa.org/en/latest/code-of-conduct.html
 
diff --git a/docs/intro.rst b/docs/intro.rst
index 12f67d7..0f5132b 100644
--- a/docs/intro.rst
+++ b/docs/intro.rst
@@ -167,13 +167,14 @@ Quick help is available on the command line::
       --benchmark        measure processing speed
 
     Configuration:
-      The project options are read from the [pep8] section of the tox.ini
-      file or the setup.cfg file located in any parent folder of the path(s)
-      being processed.  Allowed options are: exclude, filename, select,
+      The project options are read from the [pycodestyle] section of the
+      tox.ini file or the setup.cfg file located in any parent folder of the
+      path(s) being processed.  Allowed options are: exclude, filename, select,
       ignore, max-line-length, hang-closing, count, format, quiet, show-pep8,
       show-source, statistics, verbose.
 
-      --config=path      user config file location (default: ~/.config/pep8)
+      --config=path      user config file location
+      (default: ~/.config/pycodestyle)
 
 
 Configuration
@@ -184,23 +185,23 @@ The behaviour may be configured at two levels, the user and project levels.
 At the user level, settings are read from the following locations:
 
 If on Windows:
-    ``~\.pep8``
+    ``~\.pycodestyle``
 
 Otherwise, if the :envvar:`XDG_CONFIG_HOME` environment variable is defined:
-    ``XDG_CONFIG_HOME/pep8``
+    ``XDG_CONFIG_HOME/pycodestyle``
 
 Else if :envvar:`XDG_CONFIG_HOME` is not defined:
-    ``~/.config/pep8``
+    ``~/.config/pycodestyle``
 
 Example::
 
-  [pep8]
+  [pycodestyle]
   ignore = E226,E302,E41
   max-line-length = 160
 
 At the project level, a ``setup.cfg`` file or a ``tox.ini`` file is read if
-present. If none of these files have a ``[pep8]`` section, no project specific
-configuration is loaded.
+present. If none of these files have a ``[pycodestyle]`` section, no project
+specific configuration is loaded.
 
 
 Error codes
@@ -321,6 +322,8 @@ This is the current list of error and warning codes:
 +------------+----------------------------------------------------------------------+
 | E304       | blank lines found after function decorator                           |
 +------------+----------------------------------------------------------------------+
+| E305       | expected 2 blank lines after end of function or class                |
++------------+----------------------------------------------------------------------+
 +------------+----------------------------------------------------------------------+
 | **E4**     | *Import*                                                             |
 +------------+----------------------------------------------------------------------+
@@ -358,6 +361,12 @@ This is the current list of error and warning codes:
 +------------+----------------------------------------------------------------------+
 | E731       | do not assign a lambda expression, use a def                         |
 +------------+----------------------------------------------------------------------+
+| E741       | do not use variables named 'l', 'O', or 'I'                          |
++------------+----------------------------------------------------------------------+
+| E742       | do not define classes named 'l', 'O', or 'I'                         |
++------------+----------------------------------------------------------------------+
+| E743       | do not define functions named 'l', 'O', or 'I'                       |
++------------+----------------------------------------------------------------------+
 +------------+----------------------------------------------------------------------+
 | **E9**     | *Runtime*                                                            |
 +------------+----------------------------------------------------------------------+
diff --git a/pycodestyle.egg-info/PKG-INFO b/pycodestyle.egg-info/PKG-INFO
index 1f5a696..627b221 100644
--- a/pycodestyle.egg-info/PKG-INFO
+++ b/pycodestyle.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pycodestyle
-Version: 2.0.0
+Version: 2.1.0
 Summary: Python style guide checker
 Home-page: https://pycodestyle.readthedocs.io/
 Author: Ian Lee
@@ -9,6 +9,22 @@ License: Expat license
 Description: pycodestyle (formerly called pep8) - Python style guide checker
         ===============================================================
         
+        .. image:: https://img.shields.io/travis/PyCQA/pycodestyle.svg
+           :target: https://travis-ci.org/PyCQA/pycodestyle
+           :alt: Build status
+        
+        .. image:: https://readthedocs.org/projects/pycodestyle/badge/?version=latest
+            :target: https://pycodestyle.readthedocs.io
+            :alt: Documentation Status
+        
+        .. image:: https://img.shields.io/pypi/wheel/pycodestyle.svg
+           :target: https://pypi.python.org/pypi/pycodestyle
+           :alt: Wheel Status
+        
+        .. image:: https://badges.gitter.im/PyCQA/pycodestyle.svg
+           :alt: Join the chat at https://gitter.im/PyCQA/pycodestyle
+           :target: https://gitter.im/PyCQA/pycodestyle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
+        
         pycodestyle is a tool to check your Python code against some of the style
         conventions in `PEP 8`_.
         
@@ -17,8 +33,12 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
         .. note::
         
             This package used to be called ``pep8`` but was renamed to ``pycodestyle``
-            to reduce confusion. Further discussion `here
-            <https://github.com/PyCQA/pycodestyle/issues/466>`_.
+            to reduce confusion. Further discussion can be found `in the issue where
+            Guido requested this
+            change <https://github.com/PyCQA/pycodestyle/issues/466>`_, or in the
+            lightning talk at PyCon 2016 by @IanLee1521:
+            `slides <https://speakerdeck.com/ianlee1521/pep8-vs-pep-8>`_
+            `video <https://youtu.be/PulzIT8KYLk?t=36m>`_.
         
         Features
         --------
@@ -35,7 +55,7 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
         Installation
         ------------
         
-        You can install, upgrade, uninstall ``pycodestyle.py`` with these commands::
+        You can install, upgrade, and uninstall ``pycodestyle.py`` with these commands::
         
           $ pip install pycodestyle
           $ pip install --upgrade pycodestyle
@@ -91,14 +111,6 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
         Links
         -----
         
-        .. image:: https://api.travis-ci.org/PyCQA/pycodestyle.png?branch=master
-           :target: https://travis-ci.org/PyCQA/pycodestyle
-           :alt: Build status
-        
-        .. image:: https://pypip.in/wheel/pycodestyle/badge.png?branch=master
-           :target: https://pypi.python.org/pypi/pycodestyle
-           :alt: Wheel Status
-        
         * `Read the documentation <https://pycodestyle.readthedocs.io/>`_
         
         * `Fork me on GitHub <http://github.com/PyCQA/pycodestyle>`_
@@ -107,6 +119,29 @@ Description: pycodestyle (formerly called pep8) - Python style guide checker
         Changelog
         =========
         
+        2.1.0 (unreleased)
+        ------------------
+        
+        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
+        
+        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)
         ------------------
diff --git a/pycodestyle.egg-info/SOURCES.txt b/pycodestyle.egg-info/SOURCES.txt
index 167d7ae..7e4b2fe 100644
--- a/pycodestyle.egg-info/SOURCES.txt
+++ b/pycodestyle.egg-info/SOURCES.txt
@@ -2,6 +2,7 @@ CHANGES.txt
 CONTRIBUTING.rst
 MANIFEST.in
 README.rst
+dev-requirements.txt
 pycodestyle.py
 setup.cfg
 setup.py
diff --git a/pycodestyle.py b/pycodestyle.py
index 7026396..df79877 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -48,33 +48,35 @@ W warnings
 """
 from __future__ import with_statement
 
+import inspect
+import keyword
 import os
-import sys
 import re
+import sys
 import time
-import inspect
-import keyword
 import tokenize
 import warnings
-from optparse import OptionParser
+
 from fnmatch import fnmatch
+from optparse import OptionParser
+
 try:
     from configparser import RawConfigParser
     from io import TextIOWrapper
 except ImportError:
     from ConfigParser import RawConfigParser
 
-__version__ = '2.0.0'
+__version__ = '2.1.0'
 
 DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox'
 DEFAULT_IGNORE = 'E121,E123,E126,E226,E24,E704,W503'
 try:
     if sys.platform == 'win32':
-        USER_CONFIG = os.path.expanduser(r'~\.pep8')
+        USER_CONFIG = os.path.expanduser(r'~\.pycodestyle')
     else:
         USER_CONFIG = os.path.join(
             os.getenv('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'),
-            'pep8'
+            'pycodestyle'
         )
 except ImportError:
     USER_CONFIG = None
@@ -197,7 +199,7 @@ def trailing_blank_lines(physical_line, lines, line_number, total_lines):
             return len(physical_line), "W292 no newline at end of file"
 
 
-def maximum_line_length(physical_line, max_line_length, multiline):
+def maximum_line_length(physical_line, max_line_length, multiline, noqa):
     r"""Limit all lines to a maximum of 79 characters.
 
     There are still many devices around that are limited to 80 character
@@ -211,7 +213,7 @@ def maximum_line_length(physical_line, max_line_length, multiline):
     """
     line = physical_line.rstrip()
     length = len(line)
-    if length > max_line_length and not noqa(line):
+    if length > max_line_length and not noqa:
         # Special case for long URLs in multi-line docstrings or comments,
         # but still report the error when the 72 first chars are whitespaces.
         chunks = line.split()
@@ -236,7 +238,9 @@ def maximum_line_length(physical_line, max_line_length, multiline):
 
 
 def blank_lines(logical_line, blank_lines, indent_level, line_number,
-                blank_before, previous_logical, previous_indent_level):
+                blank_before, previous_logical,
+                previous_unindented_logical_line, previous_indent_level,
+                lines):
     r"""Separate top-level function and class definitions with two blank lines.
 
     Method definitions inside a class are separated by a single blank line.
@@ -248,13 +252,16 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
     Use blank lines in functions, sparingly, to indicate logical sections.
 
     Okay: def a():\n    pass\n\n\ndef b():\n    pass
+    Okay: def a():\n    pass\n\n\nasync def b():\n    pass
     Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
 
     E301: class Foo:\n    b = 0\n    def bar():\n        pass
     E302: def a():\n    pass\n\ndef b(n):\n    pass
+    E302: def a():\n    pass\n\nasync def b(n):\n    pass
     E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
     E303: def a():\n\n\n\n    pass
     E304: @decorator\n\ndef a():\n    pass
+    E305: def a():\n    pass\na()
     """
     if line_number < 3 and not previous_logical:
         return  # Don't expect blank lines before the first line
@@ -263,13 +270,30 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
             yield 0, "E304 blank lines found after function decorator"
     elif blank_lines > 2 or (indent_level and blank_lines == 2):
         yield 0, "E303 too many blank lines (%d)" % blank_lines
-    elif logical_line.startswith(('def ', 'class ', '@')):
+    elif logical_line.startswith(('def ', 'async def', 'class ', '@')):
         if indent_level:
             if not (blank_before or previous_indent_level < indent_level or
                     DOCSTRING_REGEX.match(previous_logical)):
-                yield 0, "E301 expected 1 blank line, found 0"
+                ancestor_level = indent_level
+                nested = False
+                # Search backwards for a def ancestor or tree root (top level).
+                for line in lines[line_number - 2::-1]:
+                    if line.strip() and expand_indent(line) < ancestor_level:
+                        ancestor_level = expand_indent(line)
+                        nested = line.lstrip().startswith('def ')
+                        if nested or ancestor_level == 0:
+                            break
+                if nested:
+                    yield 0, "E306 expected 1 blank line before a " \
+                        "nested definition, found 0"
+                else:
+                    yield 0, "E301 expected 1 blank line, found 0"
         elif blank_before != 2:
             yield 0, "E302 expected 2 blank lines, found %d" % blank_before
+    elif (logical_line and not indent_level and blank_before != 2 and
+          previous_unindented_logical_line.startswith(('def', 'class'))):
+        yield 0, "E305 expected 2 blank lines after " \
+            "class or function definition, found %d" % blank_before
 
 
 def extraneous_whitespace(logical_line):
@@ -958,22 +982,25 @@ def compound_statements(logical_line):
     line = logical_line
     last_char = len(line) - 1
     found = line.find(':')
+    prev_found = 0
+    counts = dict((char, 0) for char in '{}[]()')
     while -1 < found < last_char:
-        before = line[:found]
-        if ((before.count('{') <= before.count('}') and   # {'a': 1} (dict)
-             before.count('[') <= before.count(']') and   # [1:2] (slice)
-             before.count('(') <= before.count(')'))):    # (annotation)
-            lambda_kw = LAMBDA_REGEX.search(before)
+        update_counts(line[prev_found:found], counts)
+        if ((counts['{'] <= counts['}'] and   # {'a': 1} (dict)
+             counts['['] <= counts[']'] and   # [1:2] (slice)
+             counts['('] <= counts[')'])):    # (annotation)
+            lambda_kw = LAMBDA_REGEX.search(line, 0, found)
             if lambda_kw:
                 before = line[:lambda_kw.start()].rstrip()
                 if before[-1:] == '=' and isidentifier(before[:-1].strip()):
                     yield 0, ("E731 do not assign a lambda expression, use a "
                               "def")
                 break
-            if before.startswith('def '):
+            if line.startswith('def '):
                 yield 0, "E704 multiple statements on one line (def)"
             else:
                 yield found, "E701 multiple statements on one line (colon)"
+        prev_found = found
         found = line.find(':', found + 1)
     found = line.find(';')
     while -1 < found:
@@ -1150,6 +1177,58 @@ def comparison_type(logical_line, noqa):
         yield match.start(), "E721 do not compare types, use 'isinstance()'"
 
 
+def ambiguous_identifier(logical_line, tokens):
+    r"""Never use the characters 'l', 'O', or 'I' as variable names.
+
+    In some fonts, these characters are indistinguishable from the numerals
+    one and zero. When tempted to use 'l', use 'L' instead.
+
+    Okay: L = 0
+    Okay: o = 123
+    Okay: i = 42
+    E741: l = 0
+    E741: O = 123
+    E741: I = 42
+
+    Variables can be bound in several other contexts, including class and
+    function definitions, 'global' and 'nonlocal' statements, exception
+    handlers, and 'with' statements.
+
+    Okay: except AttributeError as o:
+    Okay: with lock as L:
+    E741: except AttributeError as O:
+    E741: with lock as l:
+    E741: global I
+    E741: nonlocal l
+    E742: class I(object):
+    E743: def l(x):
+    """
+    idents_to_avoid = ('l', 'O', 'I')
+    prev_type, prev_text, prev_start, prev_end, __ = tokens[0]
+    for token_type, text, start, end, line in tokens[1:]:
+        ident = pos = None
+        # identifiers on the lhs of an assignment operator
+        if token_type == tokenize.OP and '=' in text:
+            if prev_text in idents_to_avoid:
+                ident = prev_text
+                pos = prev_start
+        # identifiers bound to a value with 'as', 'global', or 'nonlocal'
+        if prev_text in ('as', 'global', 'nonlocal'):
+            if text in idents_to_avoid:
+                ident = text
+                pos = start
+        if prev_text == 'class':
+            if text in idents_to_avoid:
+                yield start, "E742 ambiguous class definition '%s'" % text
+        if prev_text == 'def':
+            if text in idents_to_avoid:
+                yield start, "E743 ambiguous function definition '%s'" % text
+        if ident:
+            yield pos, "E741 ambiguous variable name '%s'" % ident
+        prev_text = text
+        prev_start = start
+
+
 def python_3000_has_key(logical_line, noqa):
     r"""The {}.has_key() method is removed in Python 3: use the 'in' operator.
 
@@ -1219,7 +1298,7 @@ else:
             with open(filename, 'rb') as f:
                 (coding, lines) = tokenize.detect_encoding(f.readline)
                 f = TextIOWrapper(f, coding, line_buffering=True)
-                return [l.decode(coding) for l in lines] + f.readlines()
+                return [line.decode(coding) for line in lines] + f.readlines()
         except (LookupError, SyntaxError, UnicodeError):
             # Fall back if file encoding is improperly declared
             with open(filename, encoding='latin-1') as f:
@@ -1333,8 +1412,18 @@ def filename_match(filename, patterns, default=True):
     return any(fnmatch(filename, pattern) for pattern in patterns)
 
 
+def update_counts(s, counts):
+    r"""Adds one to the counts of each appearance of characters in s,
+        for characters in counts"""
+    for char in s:
+        if char in counts:
+            counts[char] += 1
+
+
 def _is_eol_token(token):
     return token[0] in NEWLINE or token[4][token[3][1]:].lstrip() == '\\\n'
+
+
 if COMMENT_WITH_NL:
     def _is_eol_token(token, _eol_token=_is_eol_token):
         return _eol_token(token) or (token[0] == tokenize.COMMENT and
@@ -1384,6 +1473,8 @@ def init_checks_registry():
     mod = inspect.getmodule(register_check)
     for (name, function) in inspect.getmembers(mod, inspect.isfunction):
         register_check(function)
+
+
 init_checks_registry()
 
 
@@ -1431,6 +1522,7 @@ class Checker(object):
                     self.lines[0] = self.lines[0][3:]
         self.report = report or options.report
         self.report_error = self.report.error
+        self.noqa = False
 
     def report_invalid_syntax(self):
         """Check if the syntax is valid."""
@@ -1541,6 +1633,8 @@ class Checker(object):
         if self.logical_line:
             self.previous_indent_level = self.indent_level
             self.previous_logical = self.logical_line
+            if not self.indent_level:
+                self.previous_unindented_logical_line = self.logical_line
         self.blank_lines = 0
         self.tokens = []
 
@@ -1565,6 +1659,7 @@ class Checker(object):
             for token in tokengen:
                 if token[2][0] > self.total_lines:
                     return
+                self.noqa = token[4] and noqa(token[4])
                 self.maybe_check_physical(token)
                 yield token
         except (SyntaxError, tokenize.TokenError):
@@ -1610,6 +1705,7 @@ class Checker(object):
         self.indent_char = None
         self.indent_level = self.previous_indent_level = 0
         self.previous_logical = ''
+        self.previous_unindented_logical_line = ''
         self.tokens = []
         self.blank_lines = self.blank_before = 0
         parens = 0
@@ -1952,7 +2048,7 @@ class StyleGuide(object):
         return sorted(checks)
 
 
-def get_parser(prog='pep8', version=__version__):
+def get_parser(prog='pycodestyle', version=__version__):
     """Create the parser for the program."""
     parser = OptionParser(prog=prog, version=version,
                           usage="%prog [options] input ...")
@@ -2020,7 +2116,7 @@ def read_config(options, args, arglist, parser):
     If a config file is specified on the command line with the "--config"
     option, then only it is used for configuration.
 
-    Otherwise, the user configuration (~/.config/pep8) and any local
+    Otherwise, the user configuration (~/.config/pycodestyle) and any local
     configurations in the current directory or above will be merged together
     (in that order) using the read method of ConfigParser.
     """
@@ -2049,8 +2145,14 @@ def read_config(options, args, arglist, parser):
             print('cli configuration: %s' % cli_conf)
         config.read(cli_conf)
 
-    pep8_section = parser.prog
-    if config.has_section(pep8_section):
+    pycodestyle_section = None
+    if config.has_section(parser.prog):
+        pycodestyle_section = parser.prog
+    elif config.has_section('pep8'):
+        pycodestyle_section = 'pep8'  # Deprecated
+        warnings.warn('[pep8] section is deprecated. Use [pycodestyle].')
+
+    if pycodestyle_section:
         option_list = dict([(o.dest, o.type or o.action)
                             for o in parser.option_list])
 
@@ -2058,23 +2160,23 @@ def read_config(options, args, arglist, parser):
         (new_options, __) = parser.parse_args([])
 
         # Second, parse the configuration
-        for opt in config.options(pep8_section):
+        for opt in config.options(pycodestyle_section):
             if opt.replace('_', '-') not in parser.config_options:
                 print("  unknown option '%s' ignored" % opt)
                 continue
             if options.verbose > 1:
-                print("  %s = %s" % (opt, config.get(pep8_section, opt)))
+                print("  %s = %s" % (opt,
+                                     config.get(pycodestyle_section, opt)))
             normalized_opt = opt.replace('-', '_')
             opt_type = option_list[normalized_opt]
             if opt_type in ('int', 'count'):
-                value = config.getint(pep8_section, opt)
-            elif opt_type == 'string':
-                value = config.get(pep8_section, opt)
+                value = config.getint(pycodestyle_section, opt)
+            elif opt_type in ('store_true', 'store_false'):
+                value = config.getboolean(pycodestyle_section, opt)
+            else:
+                value = config.get(pycodestyle_section, opt)
                 if normalized_opt == 'exclude':
                     value = normalize_paths(value, local_dir)
-            else:
-                assert opt_type in ('store_true', 'store_false')
-                value = config.getboolean(pep8_section, opt)
             setattr(new_options, normalized_opt, value)
 
         # Third, overwrite with the command-line options
@@ -2088,7 +2190,7 @@ def process_options(arglist=None, parse_argv=False, config_file=None,
     """Process options passed either via arglist or via command line args.
 
     Passing in the ``config_file`` parameter allows other tools, such as flake8
-    to specify their own options to be processed in pep8.
+    to specify their own options to be processed in pycodestyle.
     """
     if not parser:
         parser = get_parser()
diff --git a/setup.cfg b/setup.cfg
index 8a0ad57..2be7508 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,7 +1,7 @@
 [wheel]
 universal = 1
 
-[pep8]
+[pycodestyle]
 select = 
 ignore = E226,E24
 max_line_length = 79
diff --git a/testsuite/E10.py b/testsuite/E10.py
index cd142e3..7b42594 100644
--- a/testsuite/E10.py
+++ b/testsuite/E10.py
@@ -38,4 +38,8 @@ def test_keys(self):
 	u'Norrbotten',
 	u'V\xe4sterbotten',
     ])
-#:
+#: E101 W191
+if True:
+    print("""
+	tab at start of this line
+""")
diff --git a/testsuite/E12not.py b/testsuite/E12not.py
index e76ef13..18c6a64 100644
--- a/testsuite/E12not.py
+++ b/testsuite/E12not.py
@@ -139,6 +139,7 @@ def long_function_name(
         var_four):
     print(var_one)
 
+
 if ((row < 0 or self.moduleCount <= row or
      col < 0 or self.moduleCount <= col)):
     raise Exception("%s,%s - %s" % (row, col, self.moduleCount))
@@ -400,6 +401,7 @@ def unicode2html(s):
                             .replace('"', '"')
                             .replace('\n', '<br>\n'))
 
+
 #
 parser.add_option('--count', action='store_true',
                   help="print total number of errors and warnings "
@@ -616,6 +618,7 @@ def other_example():
         for key, val in node.items()
     ))]
 
+
 foo([
     'bug'
 ])
diff --git a/testsuite/E22.py b/testsuite/E22.py
index 9d8efda..ee9dc74 100644
--- a/testsuite/E22.py
+++ b/testsuite/E22.py
@@ -150,6 +150,7 @@ if alpha[:-i]:
 def squares(n):
     return (i**2 for i in range(n))
 
+
 ENG_PREFIXES = {
     -6: "\u03bc",  # Greek letter mu
     -3: "m",
diff --git a/testsuite/E30.py b/testsuite/E30.py
index d2d7bf3..105d368 100644
--- a/testsuite/E30.py
+++ b/testsuite/E30.py
@@ -44,7 +44,13 @@ def a():
 def b():
     pass
 #:
+#: E302:4:1
+def a():
+    pass
 
+async def b():
+    pass
+#:
 
 #: E303:5:1
... 361 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pycodestyle.git



More information about the Python-modules-commits mailing list