From e7d9ce052b3838e1c126a8651e79ff1fc822f740 Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Tue, 22 Feb 2022 19:40:34 +0800 Subject: [PATCH 1/6] Fix typos --- CHANGELOG | 2 +- README.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ebaf0f2..39a5ad7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -33,7 +33,7 @@ ----- - Test on Python 3.7 -- Escape a regex tring with r"" +- Escape a regex string with r"" 1.0.1 ----- diff --git a/README.rst b/README.rst index 58bc0e0..ae0abed 100644 --- a/README.rst +++ b/README.rst @@ -98,7 +98,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 ======================================== From af26c2444c79d2ea443e36f64ef0a8cf0e2b24c2 Mon Sep 17 00:00:00 2001 From: Erik Kemperman Date: Sun, 17 Oct 2021 00:41:51 +0200 Subject: [PATCH 2/6] Remove Python 2 support and dependency on py, fixes #81 --- pytest_flake8.py | 29 ++++++++++++++++++----------- setup.py | 6 +++--- tox.ini | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/pytest_flake8.py b/pytest_flake8.py index 1e45d8f..5774714 100644 --- a/pytest_flake8.py +++ b/pytest_flake8.py @@ -2,12 +2,12 @@ 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' @@ -116,15 +116,22 @@ def setup(self): 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.maxcomplexity, + self.showshource, + 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 diff --git a/setup.py b/setup.py index 50e91c9..1dfdf3c 100644 --- a/setup.py +++ b/setup.py @@ -14,13 +14,13 @@ "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.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", diff --git a/tox.ini b/tox.ini index 12da49e..343cfdd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py27,py36-pytesttrunk,py36-xdist,py34,py35,py36,py37,py38,pypy,pypy3 +envlist=py36-pytesttrunk,py36-xdist,py35,py36,py37,py38,py39,py310,pypy,pypy3 [testenv] deps=pytest From 48dd965cdce23fbda69c1853fb43e283c208dcd5 Mon Sep 17 00:00:00 2001 From: Erik Kemperman Date: Wed, 22 Dec 2021 13:02:45 +0100 Subject: [PATCH 3/6] Forgot to amend travis.yml --- .travis.yml | 10 ++++------ tox.ini | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 125fb76..91f0e8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,6 @@ language: python cache: pip matrix: include: - - python: 2.7 - env: TOXENV=py27 - - python: 3.4 - env: TOXENV=py34 - python: 3.5 env: TOXENV=py35 - python: 3.6 @@ -19,8 +15,10 @@ matrix: env: TOXENV=py37 - python: 3.8 env: TOXENV=py38 - - python: pypy2.7-6.0 - env: TOXENV=pypy + - python: 3.9 + env: TOXENV=py39 + - python: 3.10 + env: TOXENV=py310 - python: pypy3.5-6.0 env: TOXENV=pypy3 install: diff --git a/tox.ini b/tox.ini index 343cfdd..a74106f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py36-pytesttrunk,py36-xdist,py35,py36,py37,py38,py39,py310,pypy,pypy3 +envlist=py36-pytesttrunk,py36-xdist,py35,py36,py37,py38,py39,py310,pypy3 [testenv] deps=pytest From e8624d5d335fa6539a10a498ec4c92faee2baa59 Mon Sep 17 00:00:00 2001 From: Rodrigo Mologni Date: Sat, 4 Dec 2021 12:42:23 -0300 Subject: [PATCH 4/6] feat: add 'flake8-max-doc-length' --- README.rst | 8 +++++--- pytest_flake8.py | 13 ++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index ae0abed..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 [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`_). diff --git a/pytest_flake8.py b/pytest_flake8.py index 5774714..6aa31c7 100644 --- a/pytest_flake8.py +++ b/pytest_flake8.py @@ -29,6 +29,9 @@ def pytest_addoption(parser): parser.addini( "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") @@ -48,6 +51,7 @@ 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._flake8statistics = config.getini("flake8-statistics") @@ -67,6 +71,7 @@ def pytest_collect_file(path, parent): item = Flake8Item.from_parent(parent, fspath=path) item.flake8ignore = flake8ignore item.maxlength = config._flake8maxlen + item.maxdoclength = config._flake8maxdoclen item.maxcomplexity = config._flake8maxcomplexity item.showshource = config._flake8showshource item.statistics = config._flake8statistics @@ -77,6 +82,7 @@ def pytest_collect_file(path, parent): parent, flake8ignore=flake8ignore, maxlength=config._flake8maxlen, + maxdoclength=config._flake8maxdoclen, maxcomplexity=config._flake8maxcomplexity, showshource=config._flake8showshource, statistics=config._flake8statistics) @@ -95,12 +101,14 @@ class Flake8Error(Exception): class Flake8Item(pytest.Item, pytest.File): def __init__(self, fspath, parent, flake8ignore=None, maxlength=None, + maxdoclength=None, maxcomplexity=None, showshource=None, statistics=None): super(Flake8Item, self).__init__(fspath, parent) self._nodeid += "::FLAKE8" self.add_marker("flake8") self.flake8ignore = flake8ignore self.maxlength = maxlength + self.maxdoclength = maxdoclength self.maxcomplexity = maxcomplexity self.showshource = showshource self.statistics = statistics @@ -123,6 +131,7 @@ def runtest(self): self.fspath, self.flake8ignore, self.maxlength, + self.maxdoclength, self.maxcomplexity, self.showshource, self.statistics @@ -186,12 +195,14 @@ def __call__(self, path): return l -def check_file(path, flake8ignore, maxlength, maxcomplexity, +def check_file(path, flake8ignore, maxlength, maxdoclenght, maxcomplexity, showshource, 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: From 290f4a8c5b2a8a091f499b973ff826e2a2ac4be2 Mon Sep 17 00:00:00 2001 From: Thorsten Lockert Date: Fri, 4 Mar 2022 22:31:01 -0700 Subject: [PATCH 5/6] Stop testing on unsupported Python version Only run tests on Python >= 3.7, older versions are no longer supported. --- CHANGELOG | 6 ++++++ tox.ini | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 39a5ad7..2609a13 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +1.1.0 +----- + +- Drop Python 2 support and dependency on py; from @erikkemperman +- Stop testing on Python versions prior to 3.7 + 1.0.7 ----- diff --git a/tox.ini b/tox.ini index a74106f..0a522a1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,16 @@ [tox] -envlist=py36-pytesttrunk,py36-xdist,py35,py36,py37,py38,py39,py310,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= From 3730b90d72b81232a6f62b2ba0f443d9554965d8 Mon Sep 17 00:00:00 2001 From: Thorsten Lockert Date: Fri, 4 Mar 2022 22:58:39 -0700 Subject: [PATCH 6/6] Update travis configuration Drop unsupported versions of Python from the travis configuration as well. --- .travis.yml | 14 +++++--------- CHANGELOG | 1 + 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91f0e8d..4bfa7f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,14 +3,10 @@ language: python cache: pip matrix: include: - - python: 3.5 - env: TOXENV=py35 - - python: 3.6 - env: TOXENV=py36 - - python: 3.6 - env: TOXENV=py36-pytesttrunk - - python: 3.6 - env: TOXENV=py36-xdist + - python: 3.10 + env: TOXENV=py310-pytesttrunk + - python: 3.10 + env: TOXENV=py310-xdist - python: 3.7 env: TOXENV=py37 - python: 3.8 @@ -19,7 +15,7 @@ matrix: env: TOXENV=py39 - python: 3.10 env: TOXENV=py310 - - python: pypy3.5-6.0 + - python: pypy3 env: TOXENV=pypy3 install: - pip install tox diff --git a/CHANGELOG b/CHANGELOG index 2609a13..71e115d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ - Drop Python 2 support and dependency on py; from @erikkemperman - Stop testing on Python versions prior to 3.7 +- Add a `flake8-max-doc-length` option; from @rodrigomologni 1.0.7 -----