From 1ec12d65b21837957aeb28f3e1de548421691c61 Mon Sep 17 00:00:00 2001 From: Et7f3 Date: Tue, 18 Apr 2023 02:21:16 +0200 Subject: [PATCH 1/3] Apply modification suggested by https://github.com/tholo/pytest-flake8/issues/92#issuecomment-1397583846 --- pytest_flake8.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pytest_flake8.py b/pytest_flake8.py index 2555f8a..1fdd34a 100644 --- a/pytest_flake8.py +++ b/pytest_flake8.py @@ -6,7 +6,7 @@ from io import BytesIO, TextIOWrapper from flake8.main import application -from flake8.options import config +from flake8.options.parse_args import parse_args import pytest @@ -213,21 +213,12 @@ def check_file(path, flake8ignore, maxlength, maxdoclenght, maxcomplexity, if statistics: args += ['--statistics'] app = application.Application() - 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) + app.plugins, app.options = parse_args(args) if flake8ignore: app.options.ignore = flake8ignore app.make_formatter() # fix this app.make_guide() - app.make_file_checker_manager() + app.make_file_checker_manager([]) app.run_checks([str(path)]) app.formatter.start() app.report_errors() From 73de77a09b4ed91b5b03b3bd8639c9b0d21ac916 Mon Sep 17 00:00:00 2001 From: Et7f3 Date: Tue, 18 Apr 2023 02:22:14 +0200 Subject: [PATCH 2/3] https://github.com/pytest-dev/py/issues/75#issuecomment-310840483 time to drop python2 --- test_flake8.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test_flake8.py b/test_flake8.py index 0bc2461..89854a0 100644 --- a/test_flake8.py +++ b/test_flake8.py @@ -2,7 +2,6 @@ """Unit tests for flake8 pytest plugin.""" from __future__ import print_function -import py import pytest pytest_plugins = "pytester", @@ -164,13 +163,13 @@ def test_unicode_error(testdir): x = testdir.tmpdir.join("x.py") import codecs f = codecs.open(str(x), "w", encoding="utf8") - f.write(py.builtin._totext(""" + f.write(""" # coding=utf8 accent_map = { u'\\xc0': 'a', # À -> a non-ascii comment crashes it } -""", "utf8")) +""") f.close() # result = testdir.runpytest("--flake8", x, "-s") # result.stdout.fnmatch_lines("*non-ascii comment*") From c1aaad8618090ba7a125e3d372da8c93526e3f29 Mon Sep 17 00:00:00 2001 From: Et7f3 Date: Tue, 18 Apr 2023 02:24:31 +0200 Subject: [PATCH 3/3] fix semantic of ignore from this 1346ddefd315223b8f476bb02381a944e14f2cbc the semantic was to only allow errorcode --- test_flake8.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_flake8.py b/test_flake8.py index 89854a0..e70860f 100644 --- a/test_flake8.py +++ b/test_flake8.py @@ -43,8 +43,8 @@ def test_default_flake8_ignores(self, testdir): [flake8] ignore = E203 - *.py E300 - tests/*.py ALL E203 # something + E300 + ALL E203 """) testdir.tmpdir.ensure("xy.py") testdir.tmpdir.ensure("tests/hello.py")