[Python-modules-commits] [python-flake8] 01/10: Import python-flake8_3.3.0.orig.tar.gz

Ondřej Nový onovy at moszumanska.debian.org
Sat Apr 8 16:02:30 UTC 2017


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

onovy pushed a commit to branch master
in repository python-flake8.

commit 2d696618b181dcd3940e8ed0daa44e3e30529686
Author: Ondřej Nový <onovy at debian.org>
Date:   Tue Feb 21 10:39:17 2017 +0100

    Import python-flake8_3.3.0.orig.tar.gz
---
 CONTRIBUTING.rst                      |   2 +
 CONTRIBUTORS.txt                      |   1 +
 PKG-INFO                              |   4 +-
 docs/source/internal/.keep            |   0
 docs/source/internal/contributing.rst |   2 +
 docs/source/internal/index.rst        |   1 +
 docs/source/internal/writing-code.rst | 220 +++++++++++++++++++++++++++++++++
 docs/source/manpage.rst               |   2 +-
 docs/source/plugin-development/.keep  |   0
 docs/source/release-notes/3.3.0.rst   |  57 +++++++++
 docs/source/release-notes/index.rst   |   1 +
 docs/source/requirements.txt          |   5 -
 docs/source/user/.keep                |   0
 docs/source/user/error-codes.rst      |  34 ++++-
 setup.cfg                             |   7 +-
 setup.py                              |  12 +-
 src/flake8.egg-info/PKG-INFO          |   4 +-
 src/flake8.egg-info/SOURCES.txt       |   8 +-
 src/flake8.egg-info/requires.txt      |   6 +-
 src/flake8/__init__.py                |   2 +-
 src/flake8/checker.py                 | 225 +++++++++++++++-------------------
 src/flake8/formatting/base.py         |  18 +++
 src/flake8/main/application.py        |  14 ++-
 src/flake8/main/git.py                |  24 +++-
 src/flake8/main/mercurial.py          |   5 +-
 src/flake8/main/options.py            |   2 +-
 src/flake8/main/setuptools_command.py |  10 +-
 src/flake8/options/manager.py         |   2 +-
 src/flake8/plugins/pyflakes.py        |  51 +++++---
 src/flake8/processor.py               |   1 +
 src/flake8/style_guide.py             |   8 ++
 tests/integration/test_checker.py     |   1 +
 tests/unit/test_checker_manager.py    |   4 +-
 tests/unit/test_file_processor.py     |   2 +-
 tests/unit/test_option_manager.py     |  17 +++
 tests/unit/test_pyflakes_codes.py     |  15 +++
 tests/unit/test_setuptools_command.py |  34 +++++
 tox.ini                               |  10 +-
 38 files changed, 622 insertions(+), 189 deletions(-)

diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 590d8e3..80ff9ac 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -163,6 +163,8 @@ Merge requests should:
 
         The final line of the body references the issue appropriately.
 
+- Follow the guidelines in :ref:`writing-code`
+
 
 Reviewing and Triaging Issues and Merge Requests
 ================================================
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 78ea654..59c227d 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -25,3 +25,4 @@ Contributors (by order of appearance) :
 - Tyrel Souza
 - Corey Farwell
 - Michael Penkov
+- Anthony Sottile
diff --git a/PKG-INFO b/PKG-INFO
index ef15976..f48785a 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: flake8
-Version: 3.2.1
+Version: 3.3.0
 Summary: the modular source code checker: pep8, pyflakes and co
 Home-page: https://gitlab.com/pycqa/flake8
 Author: Ian Cordasco
@@ -85,6 +85,7 @@ Description: ========
         <https://coglib.com/~icordasc/>`_
         
 Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
 Classifier: Environment :: Console
 Classifier: Framework :: Flake8
 Classifier: Intended Audience :: Developers
@@ -95,5 +96,6 @@ Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
 Classifier: Topic :: Software Development :: Quality Assurance
diff --git a/docs/source/internal/.keep b/docs/source/internal/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/docs/source/internal/contributing.rst b/docs/source/internal/contributing.rst
index 590d8e3..80ff9ac 100644
--- a/docs/source/internal/contributing.rst
+++ b/docs/source/internal/contributing.rst
@@ -163,6 +163,8 @@ Merge requests should:
 
         The final line of the body references the issue appropriately.
 
+- Follow the guidelines in :ref:`writing-code`
+
 
 Reviewing and Triaging Issues and Merge Requests
 ================================================
diff --git a/docs/source/internal/index.rst b/docs/source/internal/index.rst
index 06fcd13..9e31d0b 100644
--- a/docs/source/internal/index.rst
+++ b/docs/source/internal/index.rst
@@ -17,6 +17,7 @@ pull gently.
 
     contributing
     writing-documentation
+    writing-code
     releases
     start-to-finish
     checker
diff --git a/docs/source/internal/writing-code.rst b/docs/source/internal/writing-code.rst
new file mode 100644
index 0000000..de129af
--- /dev/null
+++ b/docs/source/internal/writing-code.rst
@@ -0,0 +1,220 @@
+.. _writing-code:
+
+=========================
+ Writing Code for Flake8
+=========================
+
+The maintainers of |Flake8| unsurprisingly have some opinions about the styl
+of code maintained in the project.
+
+At the time of this writing, |Flake8| enables all of PyCodeStyle's checks, all
+of PyFlakes' checks, and sets a maximum complexity value (for McCabe) of 10.
+On top of that, we enforce PEP-0257 style doc-strings via PyDocStyle
+(disabling only D203) and Google's import order style using
+flake8-import-order.
+
+The last two are a little unusual, so we provide examples below.
+
+
+PEP-0257 style doc-strings
+==========================
+
+|Flake8| attempts to document both internal interfaces as well as our API and
+doc-strings provide a very convenient way to do so. Even if a function, class,
+or method isn't included specifically in our documentation having a doc-string
+is still preferred. Further, |Flake8| has some style preferences that are not
+checked by PyDocStyle.
+
+For example, while most people will never read the doc-string for
+:func:`flake8.main.git.hook` that doc-string still provides value to the
+maintainers and future collaborators. They (very explicitly) describe the
+purpose of the function, a little of what it does, and what parameters it
+accepts as well as what it returns.
+
+.. code-block:: python
+
+    # src/flake8/main/git.py
+    def hook(lazy=False, strict=False):
+        """Execute Flake8 on the files in git's index.
+
+        Determine which files are about to be committed and run Flake8 over them
+        to check for violations.
+
+        :param bool lazy:
+            Find files not added to the index prior to committing. This is useful
+            if you frequently use ``git commit -a`` for example. This defaults to
+            False since it will otherwise include files not in the index.
+        :param bool strict:
+            If True, return the total number of errors/violations found by Flake8.
+            This will cause the hook to fail.
+        :returns:
+            Total number of errors found during the run.
+        :rtype:
+            int
+        """
+        # NOTE(sigmavirus24): Delay import of application until we need it.
+        from flake8.main import application
+        app = application.Application()
+        with make_temporary_directory() as tempdir:
+            filepaths = list(copy_indexed_files_to(tempdir, lazy))
+            app.initialize(['.'])
+            app.options.exclude = update_excludes(app.options.exclude, tempdir)
+            app.options._running_from_vcs = True
+            app.run_checks(filepaths)
+
+        app.report_errors()
+        if strict:
+            return app.result_count
+        return 0
+
+Note that because the parameters ``hook`` and ``strict`` are simply boolean
+parameters, we inline the type declaration for those parameters, e.g.,
+
+.. code-block:: restructuredtext
+
+    :param bool lazy:
+
+Also note that we begin the description of the parameter on a new-line and
+indented 4 spaces.
+
+On the other hand, we also separate the parameter type declaration in some
+places where the name is a little longer, e.g.,
+
+.. code-block:: python
+
+    # src/flake8/formatting/base.py
+    def format(self, error):
+        """Format an error reported by Flake8.
+
+        This method **must** be implemented by subclasses.
+
+        :param error:
+            This will be an instance of :class:`~flake8.style_guide.Error`.
+        :type error:
+            flake8.style_guide.Error
+        :returns:
+            The formatted error string.
+        :rtype:
+            str
+        """
+
+Here we've separated ``:param error:`` and ``:type error:``.
+
+Following the above examples and guidelines should help you write doc-strings
+that are stylistically correct for |Flake8|.
+
+
+Imports
+=======
+
+|Flake8| follows the import guidelines that Google published in their Python
+Style Guide. In short this includes:
+
+- Only importing modules
+
+- Grouping imports into
+
+  * standard library imports
+
+  * third-party dependency imports
+
+  * local application imports
+
+- Ordering imports alphabetically
+
+In practice this would look something like:
+
+.. code-block:: python
+
+    import configparser
+    import logging
+    from os import path
+
+    import requests
+
+    from flake8 import exceptions
+    from flake8.formatting import base
+
+As a result, of the above, we do not:
+
+- Import objects into a namespace to make them accessible from that namespace
+
+- Import only the objects we're using
+
+- Add commnts explaining that an import is a standard library module or
+  something else
+
+
+Other Stylistic Preferences
+===========================
+
+Finally, |Flake8| has a few other stylistic preferences that it does not
+presently enforce automatically.
+
+Multi-line Function/Method Calls
+--------------------------------
+
+When you find yourself having to split a call to a function or method up
+across multiple lines, insert a new-line after the opening parenthesis, e.g.,
+
+.. code-block:: python
+
+    # src/flake8/main/options.py
+    add_option(
+        '-v', '--verbose', default=0, action='count',
+        parse_from_config=True,
+        help='Print more information about what is happening in flake8.'
+             ' This option is repeatable and will increase verbosity each '
+             'time it is repeated.',
+    )
+
+    # src/flake8/formatting/base.py
+    def show_statistics(self, statistics):
+        """Format and print the statistics."""
+        for error_code in statistics.error_codes():
+            stats_for_error_code = statistics.statistics_for(error_code)
+            statistic = next(stats_for_error_code)
+            count = statistic.count
+            count += sum(stat.count for stat in stats_for_error_code)
+            self._write('{count:<5} {error_code} {message}'.format(
+                count=count,
+                error_code=error_code,
+                message=statistic.message,
+            ))
+
+In the first example, we put a few of the parameters all on one line, and then
+added the last two on their own. In the second example, each parameter has its
+own line. This particular rule is a little subjective. The general idea is
+that putting one parameter per-line is preferred, but sometimes it's
+reasonable and understandable to group a few together on one line.
+
+Comments
+--------
+
+If you're adding an important comment, be sure to sign it. In |Flake8| we
+generally sign comments by preceding them with ``NOTE(<name>)``. For example,
+
+.. code-block:: python
+
+    # NOTE(sigmavirus24): The format strings are a little confusing, even
+    # to me, so here's a quick explanation:
+    # We specify the named value first followed by a ':' to indicate we're
+    # formatting the value.
+    # Next we use '<' to indicate we want the value left aligned.
+    # Then '10' is the width of the area.
+    # For floats, finally, we only want only want at most 3 digits after
+    # the decimal point to be displayed. This is the precision and it
+    # can not be specified for integers which is why we need two separate
+    # format strings.
+    float_format = '{value:<10.3} {statistic}'.format
+    int_format = '{value:<10} {statistic}'.format
+
+Ian is well known across most websites as ``sigmavirus24`` so he signs his
+comments that way.
+
+Verbs Belong in Function Names
+------------------------------
+
+|Flake8| prefers that functions have verbs in them. If you're writing a
+function that returns a generator of files then ``generate_files`` will always
+be preferable to ``make_files`` or ``files``.
diff --git a/docs/source/manpage.rst b/docs/source/manpage.rst
index 4988de4..8a58cdd 100644
--- a/docs/source/manpage.rst
+++ b/docs/source/manpage.rst
@@ -72,7 +72,7 @@ All options available as of Flake8 3.1.0::
     --exit-zero           Exit with status code "0" even if there are errors.
     --install-hook=INSTALL_HOOK
                           Install a hook that is run prior to a commit for the
-                          supported version control systema.
+                          supported version control system.
     -j JOBS, --jobs=JOBS  Number of subprocesses to use to run checks in
                           parallel. This is ignored on Windows. The default,
                           "auto", will auto-detect the number of processors
diff --git a/docs/source/plugin-development/.keep b/docs/source/plugin-development/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/docs/source/release-notes/3.3.0.rst b/docs/source/release-notes/3.3.0.rst
new file mode 100644
index 0000000..982210e
--- /dev/null
+++ b/docs/source/release-notes/3.3.0.rst
@@ -0,0 +1,57 @@
+3.3.0 -- 2017-02-06
+-------------------
+
+You can view the `3.3.0 milestone`_ on GitLab for more details.
+
+- Add support for Python 3.6 (via dependencies). **Note** Flake8 does not
+  guarantee that all plugins will support Python 3.6.
+
+- Added unique error codes for all missing PyFlakes messages. (14 new
+  codes, see "Error / Violation Codes")
+
+- Dramatically improve the performance of Flake8. (See also `GitLab!156`_)
+
+- Display the local file path instead of the temporary file path when
+  using the git hook. (See also `GitLab#244`_)
+
+- Add methods to Report class that will be called when Flake8 starts and
+  finishes processing a file. (See also `GitLab#251`_)
+
+- Fix problem where hooks should only check \*.py files. (See also
+  `GitLab#268`_)
+
+- Fix handling of SyntaxErrors that do not include physical line information.
+  (See also `GitLab#279`_)
+
+- Update upper bound on PyFlakes to allow for PyFlakes 1.5.0.  (See also
+  `GitLab#290`_)
+
+- Update setuptools integration to less eagerly deduplicate packages.
+  (See also `GitLab#295`_)
+
+- Force ``flake8 --version`` to be repeatable between invocations. (See also
+  `GitLab#297`_)
+
+.. all links
+.. _3.3.0 milestone:
+    https://gitlab.com/pycqa/flake8/milestones/16
+
+.. issue links
+.. _GitLab#244:
+    https://gitlab.com/pycqa/flake8/issues/244
+.. _GitLab#251:
+    https://gitlab.com/pycqa/flake8/issues/251
+.. _GitLab#268:
+    https://gitlab.com/pycqa/flake8/issues/268
+.. _GitLab#279:
+    https://gitlab.com/pycqa/flake8/issues/279
+.. _GitLab#290:
+    https://gitlab.com/pycqa/flake8/issues/290
+.. _GitLab#295:
+    https://gitlab.com/pycqa/flake8/issues/295
+.. _GitLab#297:
+    https://gitlab.com/pycqa/flake8/issues/297
+
+.. merge request links
+.. _GitLab!156:
+    https://gitlab.com/pycqa/flake8/merge_requests/156
diff --git a/docs/source/release-notes/index.rst b/docs/source/release-notes/index.rst
index aa86351..38317de 100644
--- a/docs/source/release-notes/index.rst
+++ b/docs/source/release-notes/index.rst
@@ -9,6 +9,7 @@ with the newest releases first.
 ==================
 
 .. toctree::
+    3.3.0
     3.2.1
     3.2.0
     3.1.1
diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt
deleted file mode 100644
index 4b5907f..0000000
--- a/docs/source/requirements.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-sphinx>=1.3.0
-sphinx_rtd_theme
-sphinx-prompt
-configparser
-flake8-polyfill
diff --git a/docs/source/user/.keep b/docs/source/user/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/docs/source/user/error-codes.rst b/docs/source/user/error-codes.rst
index 8bff640..dbaf35e 100644
--- a/docs/source/user/error-codes.rst
+++ b/docs/source/user/error-codes.rst
@@ -1,3 +1,5 @@
+.. _error_codes:
+
 =========================
  Error / Violation Codes
 =========================
@@ -22,6 +24,36 @@ generates its own :term:`error code`\ s for ``pyflakes``:
 +------+---------------------------------------------------------------------+
 | F405 | ``name`` may be undefined, or defined from star imports: ``module`` |
 +------+---------------------------------------------------------------------+
+| F406 | 'from ``module`` import \*' only allowed at module level            |
++------+---------------------------------------------------------------------+
+| F407 | an undefined ``__future__`` feature name was imported               |
++------+---------------------------------------------------------------------+
++------+---------------------------------------------------------------------+
+| F601 | dictionary key ``name`` repeated with different values              |
++------+---------------------------------------------------------------------+
+| F602 | dictionary key variable ``name`` repeated with different values     |
++------+---------------------------------------------------------------------+
+| F621 | too many expressions in an assignment with star-unpacking           |
++------+---------------------------------------------------------------------+
+| F622 | two or more starred expressions in an assignment ``(a, *b, *c = d)``|
++------+---------------------------------------------------------------------+
+| F631 | assertion test is a tuple, which are always ``True``                |
++------+---------------------------------------------------------------------+
++------+---------------------------------------------------------------------+
+| F701 | a ``break`` statement outside of a ``while`` or ``for`` loop        |
++------+---------------------------------------------------------------------+
+| F702 | a ``continue`` statement outside of a ``while`` or ``for`` loop     |
++------+---------------------------------------------------------------------+
+| F703 | a ``continue`` statement in a ``finally`` block in a loop           |
++------+---------------------------------------------------------------------+
+| F704 | a ``yield`` or ``yield from`` statement outside of a function       |
++------+---------------------------------------------------------------------+
+| F705 | a ``return`` statement with arguments inside a generator            |
++------+---------------------------------------------------------------------+
+| F706 | a ``return`` statement outside of a function/method                 |
++------+---------------------------------------------------------------------+
+| F707 | an ``except:`` block as not the last exception handler              |
++------+---------------------------------------------------------------------+
 +------+---------------------------------------------------------------------+
 | F811 | redefinition of unused ``name`` from line ``N``                     |
 +------+---------------------------------------------------------------------+
@@ -29,7 +61,7 @@ generates its own :term:`error code`\ s for ``pyflakes``:
 +------+---------------------------------------------------------------------+
 | F821 | undefined name ``name``                                             |
 +------+---------------------------------------------------------------------+
-| F822 | undefined name ``name`` in __all__                                  |
+| F822 | undefined name ``name`` in ``__all__``                              |
 +------+---------------------------------------------------------------------+
 | F823 | local variable ``name`` ... referenced before assignment            |
 +------+---------------------------------------------------------------------+
diff --git a/setup.cfg b/setup.cfg
index 9c4111e..de6418f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -8,12 +8,11 @@ universal = 1
 requires-dist = 
 	enum34; python_version<"3.4"
 	configparser; python_version<"3.2"
-	pyflakes >= 0.8.1, != 1.2.0, != 1.2.1, != 1.2.2, < 1.4.0
-	pycodestyle >= 2.0.0, < 2.3.0
-	mccabe >= 0.5.0, < 0.6.0
+	pyflakes >= 1.5.0, < 1.6.0
+	pycodestyle >= 2.0.0, < 2.4.0
+	mccabe >= 0.6.0, < 0.7.0
 
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index dc346e1..5a40d9b 100644
--- a/setup.py
+++ b/setup.py
@@ -12,12 +12,14 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))  # noqa
 import flake8
 
 
-tests_require = ['mock', 'pytest']
+tests_require = ['mock >= 2.0.0', 'pytest']
 
+# NOTE(sigmavirus24): When updating these requirements, update them in
+# setup.cfg as well.
 requires = [
-    "pyflakes >= 0.8.1, != 1.2.0, != 1.2.1, != 1.2.2, < 1.4.0",
-    "pycodestyle >= 2.0.0, < 2.3.0",
-    "mccabe >= 0.5.0, < 0.6.0",
+    "pyflakes >= 1.5.0, < 1.6.0",
+    "pycodestyle >= 2.0.0, < 2.4.0",
+    "mccabe >= 0.6.0, < 0.7.0",
 ]
 
 if sys.version_info < (3, 4):
@@ -113,6 +115,7 @@ setuptools.setup(
         ],
     },
     classifiers=[
+        "Development Status :: 5 - Production/Stable",
         "Environment :: Console",
         "Framework :: Flake8",
         "Intended Audience :: Developers",
@@ -123,6 +126,7 @@ setuptools.setup(
         "Programming Language :: Python :: 3",
         "Programming Language :: Python :: 3.4",
         "Programming Language :: Python :: 3.5",
+        "Programming Language :: Python :: 3.6",
         "Topic :: Software Development :: Libraries :: Python Modules",
         "Topic :: Software Development :: Quality Assurance",
     ],
diff --git a/src/flake8.egg-info/PKG-INFO b/src/flake8.egg-info/PKG-INFO
index ef15976..f48785a 100644
--- a/src/flake8.egg-info/PKG-INFO
+++ b/src/flake8.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: flake8
-Version: 3.2.1
+Version: 3.3.0
 Summary: the modular source code checker: pep8, pyflakes and co
 Home-page: https://gitlab.com/pycqa/flake8
 Author: Ian Cordasco
@@ -85,6 +85,7 @@ Description: ========
         <https://coglib.com/~icordasc/>`_
         
 Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
 Classifier: Environment :: Console
 Classifier: Framework :: Flake8
 Classifier: Intended Audience :: Developers
@@ -95,5 +96,6 @@ Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
 Classifier: Topic :: Software Development :: Quality Assurance
diff --git a/src/flake8.egg-info/SOURCES.txt b/src/flake8.egg-info/SOURCES.txt
index 0810bff..d858eb9 100644
--- a/src/flake8.egg-info/SOURCES.txt
+++ b/src/flake8.egg-info/SOURCES.txt
@@ -12,8 +12,6 @@ docs/source/faq.rst
 docs/source/glossary.rst
 docs/source/index.rst
 docs/source/manpage.rst
-docs/source/requirements.txt
-docs/source/internal/.keep
 docs/source/internal/checker.rst
 docs/source/internal/cli.rst
 docs/source/internal/contributing.rst
@@ -24,8 +22,8 @@ docs/source/internal/plugin_handling.rst
 docs/source/internal/releases.rst
 docs/source/internal/start-to-finish.rst
 docs/source/internal/utils.rst
+docs/source/internal/writing-code.rst
 docs/source/internal/writing-documentation.rst
-docs/source/plugin-development/.keep
 docs/source/plugin-development/cross-compatibility.rst
 docs/source/plugin-development/formatters.rst
 docs/source/plugin-development/index.rst
@@ -75,8 +73,8 @@ docs/source/release-notes/3.1.0.rst
 docs/source/release-notes/3.1.1.rst
 docs/source/release-notes/3.2.0.rst
 docs/source/release-notes/3.2.1.rst
+docs/source/release-notes/3.3.0.rst
 docs/source/release-notes/index.rst
-docs/source/user/.keep
 docs/source/user/configuration.rst
 docs/source/user/error-codes.rst
 docs/source/user/ignoring-errors.rst
@@ -161,6 +159,8 @@ tests/unit/test_option_manager.py
 tests/unit/test_plugin.py
 tests/unit/test_plugin_manager.py
 tests/unit/test_plugin_type_manager.py
+tests/unit/test_pyflakes_codes.py
+tests/unit/test_setuptools_command.py
 tests/unit/test_statistics.py
 tests/unit/test_style_guide.py
 tests/unit/test_trie.py
diff --git a/src/flake8.egg-info/requires.txt b/src/flake8.egg-info/requires.txt
index 71c4e8c..ec61a0c 100644
--- a/src/flake8.egg-info/requires.txt
+++ b/src/flake8.egg-info/requires.txt
@@ -1,3 +1,3 @@
-pyflakes >= 0.8.1, != 1.2.0, != 1.2.1, != 1.2.2, < 1.4.0
-pycodestyle >= 2.0.0, < 2.3.0
-mccabe >= 0.5.0, < 0.6.0
+pyflakes >= 1.5.0, < 1.6.0
+pycodestyle >= 2.0.0, < 2.4.0
+mccabe >= 0.6.0, < 0.7.0
diff --git a/src/flake8/__init__.py b/src/flake8/__init__.py
index e6e2c22..e9c5d30 100644
--- a/src/flake8/__init__.py
+++ b/src/flake8/__init__.py
@@ -27,7 +27,7 @@ LOG.addHandler(NullHandler())
 # Clean up after LOG config
 del NullHandler
 
-__version__ = '3.2.1'
+__version__ = '3.3.0'
 __version_info__ = tuple(int(i) for i in __version__.split('.') if i.isdigit())
 
 
diff --git a/src/flake8/checker.py b/src/flake8/checker.py
index 7f148f4..a9d7cad 100644
--- a/src/flake8/checker.py
+++ b/src/flake8/checker.py
@@ -1,7 +1,9 @@
 """Checker Manager and Checker classes."""
+import collections
 import errno
 import logging
 import os
+import signal
 import sys
 import tokenize
 
@@ -10,11 +12,6 @@ try:
 except ImportError:
     multiprocessing = None
 
-try:
-    import Queue as queue
-except ImportError:
-    import queue
-
 from flake8 import defaults
 from flake8 import exceptions
 from flake8 import processor
@@ -76,10 +73,8 @@ class Manager(object):
         self.options = style_guide.options
         self.checks = checker_plugins
         self.jobs = self._job_count()
-        self.process_queue = None
-        self.results_queue = None
-        self.statistics_queue = None
         self.using_multiprocessing = self.jobs > 1
+        self.pool = None
         self.processes = []
         self.checkers = []
         self.statistics = {
@@ -91,48 +86,17 @@ class Manager(object):
 
         if self.using_multiprocessing:
             try:
-                self.process_queue = multiprocessing.Queue()
-                self.results_queue = multiprocessing.Queue()
-                self.statistics_queue = multiprocessing.Queue()
+                self.pool = multiprocessing.Pool(self.jobs, _pool_init)
             except OSError as oserr:
                 if oserr.errno not in SERIAL_RETRY_ERRNOS:
                     raise
                 self.using_multiprocessing = False
 
-    @staticmethod
-    def _cleanup_queue(q):
-        while not q.empty():
-            q.get_nowait()
-
-    def _force_cleanup(self):
-        if self.using_multiprocessing:
-            for proc in self.processes:
-                proc.join(0.2)
-            self._cleanup_queue(self.process_queue)
-            self._cleanup_queue(self.results_queue)
-            self._cleanup_queue(self.statistics_queue)
-
     def _process_statistics(self):
-        all_statistics = self.statistics
-        if self.using_multiprocessing:
-            total_number_of_checkers = len(self.checkers)
-            statistics_gathered = 0
-            while statistics_gathered < total_number_of_checkers:
-                try:
-                    statistics = self.statistics_queue.get(block=False)
-                    statistics_gathered += 1
-                except queue.Empty:
-                    break
-
-                for statistic in defaults.STATISTIC_NAMES:
-                    all_statistics[statistic] += statistics[statistic]
-        else:
-            statistics_generator = (checker.statistics
-                                    for checker in self.checkers)
-            for statistics in statistics_generator:
-                for statistic in defaults.STATISTIC_NAMES:
-                    all_statistics[statistic] += statistics[statistic]
-        all_statistics['files'] += len(self.checkers)
+        for checker in self.checkers:
+            for statistic in defaults.STATISTIC_NAMES:
+                self.statistics[statistic] += checker.statistics[statistic]
+        self.statistics['files'] += len(self.checkers)
 
     def _job_count(self):
         # type: () -> int
@@ -189,19 +153,6 @@ class Manager(object):
         # it to an integer
         return int(jobs)
 
-    def _results(self):
-        seen_done = 0
-        LOG.info('Retrieving results')
-        while True:
-            result = self.results_queue.get()
-            if result == 'DONE':
-                seen_done += 1
-                if seen_done >= self.jobs:
-                    break
-                continue
-
-            yield result
-
     def _handle_results(self, filename, results):
         style_guide = self.style_guide
         reported_results_count = 0
@@ -257,24 +208,17 @@ class Manager(object):
             paths = ['.']
 
         filename_patterns = self.options.filename
+        running_from_vcs = self.options._running_from_vcs
 
         # NOTE(sigmavirus24): Yes this is a little unsightly, but it's our
         # best solution right now.
-        def should_create_file_checker(filename):
+        def should_create_file_checker(filename, argument):
             """Determine if we should create a file checker."""
             matches_filename_patterns = utils.fnmatch(
                 filename, filename_patterns
             )
             is_stdin = filename == '-'
             file_exists = os.path.exists(filename)
-            return (file_exists and matches_filename_patterns) or is_stdin
-
-        checks = self.checks.to_dictionary()
-        self.checkers = [
-            FileChecker(filename, checks, self.options)
-            for argument in paths
-            for filename in utils.filenames_from(argument,
-                                                 self.is_path_excluded)
             # NOTE(sigmavirus24): If a user explicitly specifies something,
             # e.g, ``flake8 bin/script`` then we should run Flake8 against
             # that. Since should_create_file_checker looks to see if the
@@ -282,7 +226,22 @@ class Manager(object):
             # the event that the argument and the filename are identical.
             # If it was specified explicitly, the user intended for it to be
             # checked.
-            if argument == filename or should_create_file_checker(filename)
+            explicitly_provided = (not running_from_vcs and
+                                   (argument == filename))
+            return ((file_exists and
+                     (explicitly_provided or matches_filename_patterns)) or
+                    is_stdin)
+
+        checks = self.checks.to_dictionary()
+        checkers = (
+            FileChecker(filename, checks, self.options)
+            for argument in paths
+            for filename in utils.filenames_from(argument,
+                                                 self.is_path_excluded)
+            if should_create_file_checker(filename, argument)
+        )
+        self.checkers = [
+            checker for checker in checkers if checker.should_process
         ]
         LOG.info('Checking %d files', len(self.checkers))
 
@@ -301,37 +260,47 @@ class Manager(object):
         results_reported = results_found = 0
         for checker in self.checkers:
             results = sorted(checker.results, key=lambda tup: (tup[1], tup[2]))
-            results_reported += self._handle_results(checker.display_name,
-                                                     results)
+            filename = checker.display_name
+            with self.style_guide.processing_file(filename):
+                results_reported += self._handle_results(filename, results)
             results_found += len(results)
         return (results_found, results_reported)
 
+    def _force_cleanup(self):
+        if self.pool is not None:
+            self.pool.terminate()
+            self.pool.join()
+
     def run_parallel(self):
         """Run the checkers in parallel."""
-        LOG.info('Starting %d process workers', self.jobs)
-        for i in range(self.jobs):
-            proc = multiprocessing.Process(
-                target=_run_checks_from_queue,
-                args=(self.process_queue, self.results_queue,
-                      self.statistics_queue)
-            )
-            proc.daemon = True
-            proc.start()
-            self.processes.append(proc)
-
-        final_results = {}
-        for (filename, results) in self._results():
+        final_results = collections.defaultdict(list)
+        final_statistics = collections.defaultdict(dict)
+        pool_map = self.pool.imap_unordered(
+            _run_checks,
+            self.checkers,
+            chunksize=calculate_pool_chunksize(
+                len(self.checkers),
+                self.jobs,
+            ),
+        )
+        for ret in pool_map:
+            filename, results, statistics = ret
             final_results[filename] = results
+            final_statistics[filename] = statistics
+        self.pool.close()
+        self.pool.join()
+        self.pool = None
 
         for checker in self.checkers:
             filename = checker.display_name
-            checker.results = sorted(final_results.get(filename, []),
+            checker.results = sorted(final_results[filename],
                                      key=lambda tup: (tup[2], tup[2]))
+            checker.statistics = final_statistics[filename]
 
     def run_serial(self):
         """Run the checkers in serial."""
         for checker in self.checkers:
-            checker.run_checks(self.results_queue, self.statistics_queue)
+            checker.run_checks()
 
     def run(self):
         """Run all the checkers.
@@ -369,15 +338,6 @@ class Manager(object):
         """
         LOG.info('Making checkers')
         self.make_checkers(paths)
-        if not self.using_multiprocessing:
-            return
-
-        LOG.info('Populating process queue')
-        for checker in self.checkers:
-            self.process_queue.put(checker)
-
-        for i in range(self.jobs):
-            self.process_queue.put('DONE')
 
     def stop(self):
         """Stop checking files."""
@@ -408,13 +368,18 @@ class FileChecker(object):
         self.filename = filename
         self.checks = checks
         self.results = []
-        self.processor = self._make_processor()
-        self.display_name = self.processor.filename
         self.statistics = {
             'tokens': 0,
             'logical lines': 0,
-            'physical lines': len(self.processor.lines),
+            'physical lines': 0,
         }
+        self.processor = self._make_processor()
+        self.display_name = filename
+        self.should_process = False
+        if self.processor is not None:
+            self.display_name = self.processor.filename
+            self.should_process = not self.processor.should_ignore_file()
+            self.statistics['physical lines'] = len(self.processor.lines)
 
     def _make_processor(self):
         try:
@@ -478,19 +443,24 @@ class FileChecker(object):
             # numbers. We need to decrement the column number by 1 at
             # least.
             column_offset = 1
+            row_offset = 0
             # See also: https://gitlab.com/pycqa/flake8/issues/237
             physical_line = token[-1]
 
-            # NOTE(sigmavirus24): SyntaxErrors also don't exactly have a
-            # "physical" line so much as what was accumulated by the point
-            # tokenizing failed.
-            # See also: https://gitlab.com/pycqa/flake8/issues/237
-            lines = physical_line.rstrip('\n').split('\n')
-            row_offset = len(lines) - 1
-            logical_line = lines[0]
-            logical_line_length = len(logical_line)
-            if column > logical_line_length:
-                column = logical_line_length
+            # NOTE(sigmavirus24): Not all "tokens" have a string as the last
+            # argument. In this event, let's skip trying to find the correct
+            # column and row values.
+            if physical_line is not None:
+                # NOTE(sigmavirus24): SyntaxErrors also don't exactly have a
+                # "physical" line so much as what was accumulated by the point
+                # tokenizing failed.
+                # See also: https://gitlab.com/pycqa/flake8/issues/237
+                lines = physical_line.rstrip('\n').split('\n')
+                row_offset = len(lines) - 1
+                logical_line = lines[0]
+                logical_line_length = len(logical_line)
+                if column > logical_line_length:
+                    column = logical_line_length
             row -= row_offset
             column -= column_offset
         return row, column
@@ -592,11 +562,8 @@ class FileChecker(object):
             self.run_physical_checks(file_processor.lines[-1])
             self.run_logical_checks()
 
-    def run_checks(self, results_queue, statistics_queue):
+    def run_checks(self):
         """Run checks against the file."""
-        if self.processor.should_ignore_file():
-            return
-
         try:
             self.process_tokens()
         except exceptions.InvalidSyntax as exc:
@@ -605,13 +572,9 @@ class FileChecker(object):
 
         self.run_ast_checks()
 
-        if results_queue is not None:
-            results_queue.put((self.filename, self.results))
-
         logical_lines = self.processor.statistics['logical lines']
         self.statistics['logical lines'] = logical_lines
-        if statistics_queue is not None:
-            statistics_queue.put(self.statistics)
+        return self.filename, self.results, self.statistics
 
     def handle_comment(self, token, token_text):
         """Handle the logic when encountering a comment token."""
@@ -658,19 +621,25 @@ class FileChecker(object):
                                              override_error_line=token[4])
 
 
-def _run_checks_from_queue(process_queue, results_queue, statistics_queue):
-    LOG.info('Running checks in parallel')
-    try:
-        for checker in iter(process_queue.get, 'DONE'):
-            LOG.info('Checking "%s"', checker.filename)
... 484 lines suppressed ...

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



More information about the Python-modules-commits mailing list