summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmanuele Rocca <ema@debian.org>2022-09-07 20:06:30 +0200
committerEmanuele Rocca <ema@debian.org>2022-09-07 20:06:30 +0200
commit9804afc76856e766f8d18da053f9450f7e419a06 (patch)
tree84e176f224023c206962ea7de056b99e9209d245
parent80db78517e907322b9d7ad4ec6c93933052a7488 (diff)
New upstream version 1.1.1
-rw-r--r--CHANGELOG24
-rw-r--r--PKG-INFO288
-rw-r--r--README.rst26
-rw-r--r--pytest_flake8.egg-info/PKG-INFO288
-rw-r--r--pytest_flake8.egg-info/entry_points.txt1
-rw-r--r--pytest_flake8.egg-info/requires.txt4
-rw-r--r--pytest_flake8.py138
-rw-r--r--setup.py15
-rw-r--r--test_flake8.py6
-rw-r--r--tox.ini6
10 files changed, 438 insertions, 358 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ed2dc82..36e1fd4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,25 @@
+1.1.1
+-----
+
+- Update classifiers to indicate older versions are no longer supported
+- No longer use deprecated pytest constructs
+- Bump requirements to more accurately indicate what is currently needed
+
+1.1.0
+-----
+
+- Drop Python 2 support and dependency on py; from @erikkemperman
+- Drop support for Python 3.5, 3.6
+- Stop testing on Python versions prior to 3.7
+- Add a `flake8-max-doc-length` option; from @rodrigomologni
+- Fix some minor typos; from @kianmeng
+
+1.0.7
+-----
+
+- Implement collect() for Flake8Item; from @thomascobb
+- Document skipping behavior in README; from @jpyams
+
1.0.6
-----
@@ -27,7 +49,7 @@
-----
- Test on Python 3.7
-- Escape a regex tring with r""
+- Escape a regex string with r""
1.0.1
-----
diff --git a/PKG-INFO b/PKG-INFO
index a0b60a2..e19a70c 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,155 +1,169 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: pytest-flake8
-Version: 1.0.6
+Version: 1.1.1
Summary: pytest plugin to check FLAKE8 requirements
Home-page: https://github.com/tholo/pytest-flake8
Author: Thorsten Lockert
Author-email: tholo@sigmasoft.com
License: BSD License
-Description: pytest plugin for efficiently checking PEP8 compliance
- ======================================================
-
- .. image:: https://img.shields.io/pypi/v/pytest-flake8.svg
- :target: https://pypi.python.org/pypi/pytest-flake8
-
- .. image:: https://img.shields.io/pypi/pyversions/pytest-flake8.svg
- :target: https://pypi.python.org/pypi/pytest-flake8
-
- .. image:: https://img.shields.io/pypi/implementation/pytest-flake8.svg
- :target: https://pypi.python.org/pypi/pytest-flake8
-
- .. image:: https://img.shields.io/pypi/status/pytest-flake8.svg
- :target: https://pypi.python.org/pypi/pytest-flake8
-
- .. image:: https://travis-ci.org/tholo/pytest-flake8.svg?branch=master
- :target: https://travis-ci.org/tholo/pytest-flake8
-
- .. image:: https://img.shields.io/github/issues/tholo/pytest-flake8.svg
- :target: https://github.com/tholo/pytest-flake8/issues
-
- .. image:: https://img.shields.io/github/issues-pr/tholo/pytest-flake8.svg
- :target: https://github.com/tholo/pytest-flake8/pulls
-
- Usage
- -----
-
- Install by running the command::
-
- pip install pytest-flake8
-
- After installing it, when you run tests with the option::
-
- pytest --flake8
-
- every file ending in ``.py`` will be discovered and checked with
- flake8.
-
- .. note::
-
- If optional flake8 plugins are installed, those will
- be used automatically. No provisions have been made for
- configuring these via `pytest`_.
-
- .. warning::
-
- Running flake8 tests on your project is likely to cause a number
- of issues. The plugin allows one to configure on a per-project and
- per-file basis which errors or warnings to ignore, see
- flake8-ignore_.
-
- .. _flake8-ignore:
-
- Configuring FLAKE8 options per project and file
- -----------------------------------------------
-
- Maximum line length can be configured for the whole project
- by adding a ``flake8-max-line-length`` option to your ``setup.cfg``
- or ``tox.ini`` file like this::
-
- # content of setup.cfg
- [pytest]
- flake8-max-line-length = 99
-
- Note that the default will be what naturally comes with `flake8`_
- (which it turn gets its default from `pycodestyle`_).
-
- You may configure flake8-checking options for your project
- by adding an ``flake8-ignore`` entry to your ``setup.cfg``
- or ``tox.ini`` file like this::
-
- # content of setup.cfg
- [pytest]
- flake8-ignore = E201 E231
-
- This would globally prevent complaints about two whitespace issues.
- Rerunning with the above example will now look better::
-
- $ pytest -q --flake8
- collecting ... collected 1 items
- .
- 1 passed in 0.01 seconds
-
- If you have some files where you want to specifically ignore
- some errors or warnings you can start a flake8-ignore line with
- a glob-pattern and a space-separated list of codes::
-
- # content of setup.cfg
- [pytest]
- flake8-ignore =
- *.py E201
- doc/conf.py ALL
-
- So if you have a conf.py like this::
-
- # content of doc/conf.py
-
- func ( [1,2,3]) #this line lots PEP8 errors :)
-
- then running again with the previous example will show a single
- failure and it will ignore doc/conf.py alltogether::
-
- $ pytest --flake8 -v # verbose shows what is ignored
- ======================================= test session starts ========================================
- platform darwin -- Python 2.7.6 -- py-1.4.26 -- pytest-2.7.0 -- /Users/tholo/Source/pytest/bin/python
- cachedir: /Users/tholo/Source/pytest/src/verify/.cache
- rootdir: /Users/tholo/Source/angular/src/verify, inifile: setup.cfg
- plugins: flake8, cache
- collected 1 items
-
- myfile.py PASSED
-
- ========================================= 1 passed in 0.00 seconds =========================================
-
- Note that doc/conf.py was not considered or imported.
-
- Notes
- -----
-
- The repository of this plugin is at https://github.com/tholo/pytest-flake8
-
- For more info on `pytest`_ see http://pytest.org
-
- The code is partially based on Ronny Pfannschmidt's `pytest-codecheckers`_ plugin.
-
- .. _`pytest`: http://pytest.org
- .. _`flake8`: https://pypi.python.org/pypi/flake8
- .. _`pycodestyle`: https://pypi.python.org/pypi/pycodestyle
- .. _`pytest-codecheckers`: https://pypi.python.org/pypi/pytest-codecheckers
-
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2
-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: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
+License-File: LICENSE
+
+pytest plugin for efficiently checking PEP8 compliance
+======================================================
+
+.. image:: https://img.shields.io/pypi/v/pytest-flake8.svg
+ :target: https://pypi.python.org/pypi/pytest-flake8
+
+.. image:: https://img.shields.io/pypi/pyversions/pytest-flake8.svg
+ :target: https://pypi.python.org/pypi/pytest-flake8
+
+.. image:: https://img.shields.io/pypi/implementation/pytest-flake8.svg
+ :target: https://pypi.python.org/pypi/pytest-flake8
+
+.. image:: https://img.shields.io/pypi/status/pytest-flake8.svg
+ :target: https://pypi.python.org/pypi/pytest-flake8
+
+.. image:: https://travis-ci.org/tholo/pytest-flake8.svg?branch=master
+ :target: https://travis-ci.org/tholo/pytest-flake8
+
+.. image:: https://img.shields.io/github/issues/tholo/pytest-flake8.svg
+ :target: https://github.com/tholo/pytest-flake8/issues
+
+.. image:: https://img.shields.io/github/issues-pr/tholo/pytest-flake8.svg
+ :target: https://github.com/tholo/pytest-flake8/pulls
+
+Usage
+-----
+
+Install by running the command::
+
+ pip install pytest-flake8
+
+After installing it, when you run tests with the option::
+
+ pytest --flake8
+
+every file ending in ``.py`` will be discovered and checked with
+flake8.
+
+.. note::
+
+ If optional flake8 plugins are installed, those will
+ be used automatically. No provisions have been made for
+ configuring these via `pytest`_.
+
+.. warning::
+
+ Running flake8 tests on your project is likely to cause a number
+ of issues. The plugin allows one to configure on a per-project and
+ per-file basis which errors or warnings to ignore, see
+ flake8-ignore_.
+
+.. _flake8-ignore:
+
+Configuring FLAKE8 options per project and file
+-----------------------------------------------
+
+Maximum line length and maximum doc line length can be configured for the
+whole project by adding a ``flake8-max-line-length`` option and
+``flake8-max-doc-length`` to your ``setup.cfg`` or ``tox.ini`` file like
+this::
+
+ # content of setup.cfg
+ [tool:pytest]
+ flake8-max-line-length = 99
+ flake8-max-doc-length = 74
+
+Note that the default will be what naturally comes with `flake8`_
+(which it turn gets its default from `pycodestyle`_).
+
+You may configure flake8-checking options for your project
+by adding an ``flake8-ignore`` entry to your ``setup.cfg``
+or ``tox.ini`` file like this::
+
+ # content of setup.cfg
+ [tool:pytest]
+ flake8-ignore = E201 E231
+
+This would globally prevent complaints about two whitespace issues.
+Rerunning with the above example will now look better::
+
+ $ pytest -q --flake8
+ collecting ... collected 1 items
+ .
+ 1 passed in 0.01 seconds
+
+If you have some files where you want to specifically ignore
+some errors or warnings you can start a flake8-ignore line with
+a glob-pattern and a space-separated list of codes::
+
+ # content of setup.cfg
+ [tool:pytest]
+ flake8-ignore =
+ *.py E201
+ doc/conf.py ALL
+
+So if you have a conf.py like this::
+
+ # content of doc/conf.py
+
+ func ( [1,2,3]) #this line lots PEP8 errors :)
+
+then running again with the previous example will show a single
+failure and it will ignore doc/conf.py altogether::
+
+ $ pytest --flake8 -v # verbose shows what is ignored
+ ======================================= test session starts ========================================
+ platform darwin -- Python 2.7.6 -- py-1.4.26 -- pytest-2.7.0 -- /Users/tholo/Source/pytest/bin/python
+ cachedir: /Users/tholo/Source/pytest/src/verify/.cache
+ rootdir: /Users/tholo/Source/angular/src/verify, inifile: setup.cfg
+ plugins: flake8, cache
+ collected 1 items
+
+ myfile.py PASSED
+
+ ========================================= 1 passed in 0.00 seconds =========================================
+
+Note that doc/conf.py was not considered or imported.
+
+FAQs
+-----
+
+All the flake8 tests are skipping!
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This is by design. Clean flake8 results are cached and, unless the file is modified, not tested again.
+
+You can run with ``pytest --cache-clear --flake8`` to override this.
+
+Notes
+-----
+
+The repository of this plugin is at https://github.com/tholo/pytest-flake8
+
+For more info on `pytest`_ see http://pytest.org
+
+The code is partially based on Ronny Pfannschmidt's `pytest-codecheckers`_ plugin.
+
+.. _`pytest`: http://pytest.org
+.. _`flake8`: https://pypi.python.org/pypi/flake8
+.. _`pycodestyle`: https://pypi.python.org/pypi/pycodestyle
+.. _`pytest-codecheckers`: https://pypi.python.org/pypi/pytest-codecheckers
+
+
diff --git a/README.rst b/README.rst
index bb31237..d328e6f 100644
--- a/README.rst
+++ b/README.rst
@@ -54,13 +54,15 @@ flake8.
Configuring FLAKE8 options per project and file
-----------------------------------------------
-Maximum line length can be configured for the whole project
-by adding a ``flake8-max-line-length`` option to your ``setup.cfg``
-or ``tox.ini`` file like this::
+Maximum line length and maximum doc line length can be configured for the
+whole project by adding a ``flake8-max-line-length`` option and
+``flake8-max-doc-length`` to your ``setup.cfg`` or ``tox.ini`` file like
+this::
# content of setup.cfg
- [pytest]
+ [tool:pytest]
flake8-max-line-length = 99
+ flake8-max-doc-length = 74
Note that the default will be what naturally comes with `flake8`_
(which it turn gets its default from `pycodestyle`_).
@@ -70,7 +72,7 @@ by adding an ``flake8-ignore`` entry to your ``setup.cfg``
or ``tox.ini`` file like this::
# content of setup.cfg
- [pytest]
+ [tool:pytest]
flake8-ignore = E201 E231
This would globally prevent complaints about two whitespace issues.
@@ -86,7 +88,7 @@ some errors or warnings you can start a flake8-ignore line with
a glob-pattern and a space-separated list of codes::
# content of setup.cfg
- [pytest]
+ [tool:pytest]
flake8-ignore =
*.py E201
doc/conf.py ALL
@@ -98,7 +100,7 @@ So if you have a conf.py like this::
func ( [1,2,3]) #this line lots PEP8 errors :)
then running again with the previous example will show a single
-failure and it will ignore doc/conf.py alltogether::
+failure and it will ignore doc/conf.py altogether::
$ pytest --flake8 -v # verbose shows what is ignored
======================================= test session starts ========================================
@@ -114,6 +116,16 @@ failure and it will ignore doc/conf.py alltogether::
Note that doc/conf.py was not considered or imported.
+FAQs
+-----
+
+All the flake8 tests are skipping!
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This is by design. Clean flake8 results are cached and, unless the file is modified, not tested again.
+
+You can run with ``pytest --cache-clear --flake8`` to override this.
+
Notes
-----
diff --git a/pytest_flake8.egg-info/PKG-INFO b/pytest_flake8.egg-info/PKG-INFO
index a0b60a2..e19a70c 100644
--- a/pytest_flake8.egg-info/PKG-INFO
+++ b/pytest_flake8.egg-info/PKG-INFO
@@ -1,155 +1,169 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: pytest-flake8
-Version: 1.0.6
+Version: 1.1.1
Summary: pytest plugin to check FLAKE8 requirements
Home-page: https://github.com/tholo/pytest-flake8
Author: Thorsten Lockert
Author-email: tholo@sigmasoft.com
License: BSD License
-Description: pytest plugin for efficiently checking PEP8 compliance
- ======================================================
-
- .. image:: https://img.shields.io/pypi/v/pytest-flake8.svg
- :target: https://pypi.python.org/pypi/pytest-flake8
-
- .. image:: https://img.shields.io/pypi/pyversions/pytest-flake8.svg
- :target: https://pypi.python.org/pypi/pytest-flake8
-
- .. image:: https://img.shields.io/pypi/implementation/pytest-flake8.svg
- :target: https://pypi.python.org/pypi/pytest-flake8
-
- .. image:: https://img.shields.io/pypi/status/pytest-flake8.svg
- :target: https://pypi.python.org/pypi/pytest-flake8
-
- .. image:: https://travis-ci.org/tholo/pytest-flake8.svg?branch=master
- :target: https://travis-ci.org/tholo/pytest-flake8
-
- .. image:: https://img.shields.io/github/issues/tholo/pytest-flake8.svg
- :target: https://github.com/tholo/pytest-flake8/issues
-
- .. image:: https://img.shields.io/github/issues-pr/tholo/pytest-flake8.svg
- :target: https://github.com/tholo/pytest-flake8/pulls
-
- Usage
- -----
-
- Install by running the command::
-
- pip install pytest-flake8
-
- After installing it, when you run tests with the option::
-
- pytest --flake8
-
- every file ending in ``.py`` will be discovered and checked with
- flake8.
-
- .. note::
-
- If optional flake8 plugins are installed, those will
- be used automatically. No provisions have been made for
- configuring these via `pytest`_.
-
- .. warning::
-
- Running flake8 tests on your project is likely to cause a number
- of issues. The plugin allows one to configure on a per-project and
- per-file basis which errors or warnings to ignore, see
- flake8-ignore_.
-
- .. _flake8-ignore:
-
- Configuring FLAKE8 options per project and file
- -----------------------------------------------
-
- Maximum line length can be configured for the whole project
- by adding a ``flake8-max-line-length`` option to your ``setup.cfg``
- or ``tox.ini`` file like this::
-
- # content of setup.cfg
- [pytest]
- flake8-max-line-length = 99
-
- Note that the default will be what naturally comes with `flake8`_
- (which it turn gets its default from `pycodestyle`_).
-
- You may configure flake8-checking options for your project
- by adding an ``flake8-ignore`` entry to your ``setup.cfg``
- or ``tox.ini`` file like this::
-
- # content of setup.cfg
- [pytest]
- flake8-ignore = E201 E231
-
- This would globally prevent complaints about two whitespace issues.
- Rerunning with the above example will now look better::
-
- $ pytest -q --flake8
- collecting ... collected 1 items
- .
- 1 passed in 0.01 seconds
-
- If you have some files where you want to specifically ignore
- some errors or warnings you can start a flake8-ignore line with
- a glob-pattern and a space-separated list of codes::
-
- # content of setup.cfg
- [pytest]
- flake8-ignore =
- *.py E201
- doc/conf.py ALL
-
- So if you have a conf.py like this::
-
- # content of doc/conf.py
-
- func ( [1,2,3]) #this line lots PEP8 errors :)
-
- then running again with the previous example will show a single
- failure and it will ignore doc/conf.py alltogether::
-
- $ pytest --flake8 -v # verbose shows what is ignored
- ======================================= test session starts ========================================
- platform darwin -- Python 2.7.6 -- py-1.4.26 -- pytest-2.7.0 -- /Users/tholo/Source/pytest/bin/python
- cachedir: /Users/tholo/Source/pytest/src/verify/.cache
- rootdir: /Users/tholo/Source/angular/src/verify, inifile: setup.cfg
- plugins: flake8, cache
- collected 1 items
-
- myfile.py PASSED
-
- ========================================= 1 passed in 0.00 seconds =========================================
-
- Note that doc/conf.py was not considered or imported.
-
- Notes
- -----
-
- The repository of this plugin is at https://github.com/tholo/pytest-flake8
-
- For more info on `pytest`_ see http://pytest.org
-
- The code is partially based on Ronny Pfannschmidt's `pytest-codecheckers`_ plugin.
-
- .. _`pytest`: http://pytest.org
- .. _`flake8`: https://pypi.python.org/pypi/flake8
- .. _`pycodestyle`: https://pypi.python.org/pypi/pycodestyle
- .. _`pytest-codecheckers`: https://pypi.python.org/pypi/pytest-codecheckers
-
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2
-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: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
+License-File: LICENSE
+
+pytest plugin for efficiently checking PEP8 compliance
+======================================================
+
+.. image:: https://img.shields.io/pypi/v/pytest-flake8.svg
+ :target: https://pypi.python.org/pypi/pytest-flake8
+
+.. image:: https://img.shields.io/pypi/pyversions/pytest-flake8.svg
+ :target: https://pypi.python.org/pypi/pytest-flake8
+
+.. image:: https://img.shields.io/pypi/implementation/pytest-flake8.svg
+ :target: https://pypi.python.org/pypi/pytest-flake8
+
+.. image:: https://img.shields.io/pypi/status/pytest-flake8.svg
+ :target: https://pypi.python.org/pypi/pytest-flake8
+
+.. image:: https://travis-ci.org/tholo/pytest-flake8.svg?branch=master
+ :target: https://travis-ci.org/tholo/pytest-flake8
+
+.. image:: https://img.shields.io/github/issues/tholo/pytest-flake8.svg
+ :target: https://github.com/tholo/pytest-flake8/issues
+
+.. image:: https://img.shields.io/github/issues-pr/tholo/pytest-flake8.svg
+ :target: https://github.com/tholo/pytest-flake8/pulls
+
+Usage
+-----
+
+Install by running the command::
+
+ pip install pytest-flake8
+
+After installing it, when you run tests with the option::
+
+ pytest --flake8
+
+every file ending in ``.py`` will be discovered and checked with
+flake8.
+
+.. note::
+
+ If optional flake8 plugins are installed, those will
+ be used automatically. No provisions have been made for
+ configuring these via `pytest`_.
+
+.. warning::
+
+ Running flake8 tests on your project is likely to cause a number
+ of issues. The plugin allows one to configure on a per-project and
+ per-file basis which errors or warnings to ignore, see
+ flake8-ignore_.
+
+.. _flake8-ignore:
+
+Configuring FLAKE8 options per project and file
+-----------------------------------------------
+
+Maximum line length and maximum doc line length can be configured for the
+whole project by adding a ``flake8-max-line-length`` option and
+``flake8-max-doc-length`` to your ``setup.cfg`` or ``tox.ini`` file like
+this::
+
+ # content of setup.cfg
+ [tool:pytest]
+ flake8-max-line-length = 99
+ flake8-max-doc-length = 74
+
+Note that the default will be what naturally comes with `flake8`_
+(which it turn gets its default from `pycodestyle`_).
+
+You may configure flake8-checking options for your project
+by adding an ``flake8-ignore`` entry to your ``setup.cfg``
+or ``tox.ini`` file like this::
+
+ # content of setup.cfg
+ [tool:pytest]
+ flake8-ignore = E201 E231
+
+This would globally prevent complaints about two whitespace issues.
+Rerunning with the above example will now look better::
+
+ $ pytest -q --flake8
+ collecting ... collected 1 items
+ .
+ 1 passed in 0.01 seconds
+
+If you have some files where you want to specifically ignore
+some errors or warnings you can start a flake8-ignore line with
+a glob-pattern and a space-separated list of codes::
+
+ # content of setup.cfg
+ [tool:pytest]
+ flake8-ignore =
+ *.py E201
+ doc/conf.py ALL
+
+So if you have a conf.py like this::
+
+ # content of doc/conf.py
+
+ func ( [1,2,3]) #this line lots PEP8 errors :)
+
+then running again with the previous example will show a single
+failure and it will ignore doc/conf.py altogether::
+
+ $ pytest --flake8 -v # verbose shows what is ignored
+ ======================================= test session starts ========================================
+ platform darwin -- Python 2.7.6 -- py-1.4.26 -- pytest-2.7.0 -- /Users/tholo/Source/pytest/bin/python
+ cachedir: /Users/tholo/Source/pytest/src/verify/.cache
+ rootdir: /Users/tholo/Source/angular/src/verify, inifile: setup.cfg
+ plugins: flake8, cache
+ collected 1 items
+
+ myfile.py PASSED
+
+ ========================================= 1 passed in 0.00 seconds =========================================
+
+Note that doc/conf.py was not considered or imported.
+
+FAQs
+-----
+
+All the flake8 tests are skipping!
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This is by design. Clean flake8 results are cached and, unless the file is modified, not tested again.
+
+You can run with ``pytest --cache-clear --flake8`` to override this.
+
+Notes
+-----
+
+The repository of this plugin is at https://github.com/tholo/pytest-flake8
+
+For more info on `pytest`_ see http://pytest.org
+
+The code is partially based on Ronny Pfannschmidt's `pytest-codecheckers`_ plugin.
+
+.. _`pytest`: http://pytest.org
+.. _`flake8`: https://pypi.python.org/pypi/flake8
+.. _`pycodestyle`: https://pypi.python.org/pypi/pycodestyle
+.. _`pytest-codecheckers`: https://pypi.python.org/pypi/pytest-codecheckers
+
+
diff --git a/pytest_flake8.egg-info/entry_points.txt b/pytest_flake8.egg-info/entry_points.txt
index 99ec03c..28f1b90 100644
--- a/pytest_flake8.egg-info/entry_points.txt
+++ b/pytest_flake8.egg-info/entry_points.txt
@@ -1,3 +1,2 @@
[pytest11]
flake8 = pytest_flake8
-
diff --git a/pytest_flake8.egg-info/requires.txt b/pytest_flake8.egg-info/requires.txt
index 98bd7ce..3d322ef 100644
--- a/pytest_flake8.egg-info/requires.txt
+++ b/pytest_flake8.egg-info/requires.txt
@@ -1,2 +1,2 @@
-flake8>=3.5
-pytest>=3.5
+flake8>=4.0
+pytest>=7.0
diff --git a/pytest_flake8.py b/pytest_flake8.py
index 80d5b0a..2555f8a 100644
--- a/pytest_flake8.py
+++ b/pytest_flake8.py
@@ -2,15 +2,15 @@
import os
import re
+from contextlib import redirect_stdout, redirect_stderr
+from io import BytesIO, TextIOWrapper
from flake8.main import application
from flake8.options import config
-import py
-
import pytest
-__version__ = '0.6'
+__version__ = '1.1.1'
HISTKEY = "flake8/mtimes"
@@ -30,6 +30,9 @@ def pytest_addoption(parser):
"flake8-max-line-length",
help="maximum line length")
parser.addini(
+ "flake8-max-doc-length",
+ help="maximum doc line length")
+ parser.addini(
"flake8-max-complexity",
help="McCabe complexity threshold")
parser.addini(
@@ -48,8 +51,9 @@ def pytest_configure(config):
if config.option.flake8:
config._flake8ignore = Ignorer(config.getini("flake8-ignore"))
config._flake8maxlen = config.getini("flake8-max-line-length")
+ config._flake8maxdoclen = config.getini("flake8-max-doc-length")
config._flake8maxcomplexity = config.getini("flake8-max-complexity")
- config._flake8showshource = config.getini("flake8-show-source")
+ config._flake8showsource = config.getini("flake8-show-source")
config._flake8statistics = config.getini("flake8-statistics")
config._flake8exts = config.getini("flake8-extensions")
config.addinivalue_line('markers', "flake8: Tests which run flake8.")
@@ -57,29 +61,21 @@ def pytest_configure(config):
config._flake8mtimes = config.cache.get(HISTKEY, {})
-def pytest_collect_file(path, parent):
+def pytest_collect_file(file_path, path, parent):
"""Filter files down to which ones should be checked."""
config = parent.config
- if config.option.flake8 and path.ext in config._flake8exts:
+ if config.option.flake8 and file_path.suffix in config._flake8exts:
flake8ignore = config._flake8ignore(path)
if flake8ignore is not None:
- if hasattr(Flake8Item, "from_parent"):
- item = Flake8Item.from_parent(parent, fspath=path)
- item.flake8ignore = flake8ignore
- item.maxlength = config._flake8maxlen
- item.maxcomplexity = config._flake8maxcomplexity
- item.showshource = config._flake8showshource
- item.statistics = config._flake8statistics
- return item
- else:
- return Flake8Item(
- path,
- parent,
- flake8ignore=flake8ignore,
- maxlength=config._flake8maxlen,
- maxcomplexity=config._flake8maxcomplexity,
- showshource=config._flake8showshource,
- statistics=config._flake8statistics)
+ item = Flake8File.from_parent(
+ parent, path=file_path,
+ flake8ignore=flake8ignore,
+ maxlength=config._flake8maxlen,
+ maxdoclength=config._flake8maxdoclen,
+ maxcomplexity=config._flake8maxcomplexity,
+ showsource=config._flake8showsource,
+ statistics=config._flake8statistics)
+ return item
def pytest_unconfigure(config):
@@ -92,19 +88,37 @@ class Flake8Error(Exception):
""" indicates an error during flake8 checks. """
-class Flake8Item(pytest.Item, pytest.File):
+class Flake8File(pytest.File):
- def __init__(self, fspath, parent, flake8ignore=None, maxlength=None,
- maxcomplexity=None, showshource=None, statistics=None):
- super(Flake8Item, self).__init__(fspath, parent)
- self._nodeid += "::FLAKE8"
- self.add_marker("flake8")
+ def __init__(self, *k,
+ flake8ignore=None, maxlength=None, maxdoclength=None,
+ maxcomplexity=None, showsource=None, statistics=None,
+ **kw):
+ super().__init__(*k, **kw)
self.flake8ignore = flake8ignore
self.maxlength = maxlength
+ self.maxdoclength = maxdoclength
self.maxcomplexity = maxcomplexity
- self.showshource = showshource
+ self.showsource = showsource
self.statistics = statistics
+ def collect(self):
+ return [Flake8Item.from_parent(self, name="flake-8")]
+
+
+class Flake8Item(pytest.Item):
+
+ def __init__(self, *k, **kwargs):
+ super().__init__(*k, **kwargs)
+ self._nodeid += "::FLAKE8"
+ self.add_marker("flake8")
+ self.flake8ignore = self.parent.flake8ignore
+ self.maxlength = self.parent.maxlength
+ self.maxdoclength = self.parent.maxdoclength
+ self.maxcomplexity = self.parent.maxcomplexity
+ self.showsource = self.parent.showsource
+ self.statistics = self.parent.statistics
+
def setup(self):
if hasattr(self.config, "_flake8mtimes"):
flake8mtimes = self.config._flake8mtimes
@@ -116,15 +130,23 @@ class Flake8Item(pytest.Item, pytest.File):
pytest.skip("file(s) previously passed FLAKE8 checks")
def runtest(self):
- call = py.io.StdCapture.call
- found_errors, out, err = call(
- check_file,
- self.fspath,
- self.flake8ignore,
- self.maxlength,
- self.maxcomplexity,
- self.showshource,
- self.statistics)
+ with BytesIO() as bo, TextIOWrapper(bo, encoding='utf-8') as to, \
+ BytesIO() as be, TextIOWrapper(be, encoding='utf-8') as te, \
+ redirect_stdout(to), redirect_stderr(te):
+ found_errors = check_file(
+ self.fspath,
+ self.flake8ignore,
+ self.maxlength,
+ self.maxdoclength,
+ self.maxcomplexity,
+ self.showsource,
+ self.statistics
+ )
+ to.flush()
+ te.flush()
+ out = bo.getvalue().decode('utf-8')
+ err = be.getvalue().decode('utf-8')
+
if found_errors:
raise Flake8Error(out, err)
# update mtime only if test passed
@@ -176,42 +198,34 @@ class Ignorer:
return l
-def check_file(path, flake8ignore, maxlength, maxcomplexity,
- showshource, statistics):
+def check_file(path, flake8ignore, maxlength, maxdoclenght, maxcomplexity,
+ showsource, statistics):
"""Run flake8 over a single file, and return the number of failures."""
args = []
if maxlength:
args += ['--max-line-length', maxlength]
+ if maxdoclenght:
+ args += ['--max-doc-length', maxdoclenght]
if maxcomplexity:
args += ['--max-complexity', maxcomplexity]
- if showshource:
+ if showsource:
args += ['--show-source']
if statistics:
args += ['--statistics']
app = application.Application()
- if not hasattr(app, 'parse_preliminary_options_and_args'): # flake8 >= 3.8
- prelim_opts, remaining_args = app.parse_preliminary_options(args)
- config_finder = config.ConfigFileFinder(
- app.program,
- prelim_opts.append_config,
- config_file=prelim_opts.config,
- ignore_config_files=prelim_opts.isolated,
- )
- app.find_plugins(config_finder)
- app.register_plugin_options()
- app.parse_configuration_and_cli(config_finder, remaining_args)
- else:
- app.parse_preliminary_options_and_args(args)
- app.make_config_finder()
- app.find_plugins()
- app.register_plugin_options()
- app.parse_configuration_and_cli(args)
+ prelim_opts, remaining_args = app.parse_preliminary_options(args)
+ config_finder = config.ConfigFileFinder(
+ app.program,
+ prelim_opts.append_config,
+ config_file=prelim_opts.config,
+ ignore_config_files=prelim_opts.isolated,
+ )
+ app.find_plugins(config_finder)
+ app.register_plugin_options()
+ app.parse_configuration_and_cli(config_finder, remaining_args)
if flake8ignore:
app.options.ignore = flake8ignore
app.make_formatter() # fix this
- if hasattr(app, 'make_notifier'):
- # removed in flake8 3.7+
- app.make_notifier()
app.make_guide()
app.make_file_checker_manager()
app.run_checks([str(path)])
diff --git a/setup.py b/setup.py
index 3cf3ae3..09af752 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ from setuptools import setup
setup(
name='pytest-flake8',
- version='1.0.6',
+ version='1.1.1',
description='pytest plugin to check FLAKE8 requirements',
long_description=open("README.rst").read(),
classifiers=[
@@ -14,13 +14,12 @@ setup(
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
- "Programming Language :: Python :: 2",
- "Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.4",
- "Programming Language :: Python :: 3.5",
- "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development",
@@ -38,7 +37,7 @@ setup(
'pytest11': ['flake8 = pytest_flake8'],
},
install_requires=[
- 'flake8>=3.5',
- 'pytest>=3.5',
+ 'flake8>=4.0',
+ 'pytest>=7.0',
],
)
diff --git a/test_flake8.py b/test_flake8.py
index 96bba79..0bc2461 100644
--- a/test_flake8.py
+++ b/test_flake8.py
@@ -153,6 +153,12 @@ def test_keyword_match(testdir):
result.assert_outcomes(failed=1)
+def test_run_on_init_file(testdir):
+ d = testdir.mkpydir("tests")
+ result = testdir.runpytest("--flake8", d / "__init__.py")
+ result.assert_outcomes(passed=1)
+
+
@pytest.mark.xfail("sys.platform == 'win32'")
def test_unicode_error(testdir):
x = testdir.tmpdir.join("x.py")
diff --git a/tox.ini b/tox.ini
index 12da49e..0a522a1 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,16 +1,16 @@
[tox]
-envlist=py27,py36-pytesttrunk,py36-xdist,py34,py35,py36,py37,py38,pypy,pypy3
+envlist=py310-pytesttrunk,py310-xdist,py37,py38,py39,py310,pypy3
[testenv]
deps=pytest
commands=
pytest --junitxml={envlogdir}/junit-{envname}.xml {posargs}
-[testenv:py36-pytesttrunk]
+[testenv:py310-pytesttrunk]
pip_pre=true
deps=pytest
-[testenv:py36-xdist]
+[testenv:py310-xdist]
deps={[testenv]deps}
pytest-xdist
commands=