Preserve legacy API options in parallel checks

This commit is contained in:
linhongkuan 2026-06-25 09:49:54 +08:00
parent bb943328ef
commit 0df41b2d56
5 changed files with 85 additions and 10 deletions

View file

@ -2,6 +2,7 @@
from __future__ import annotations
from flake8.api import legacy
from flake8.main.options import JobsArgument
def test_legacy_api(tmpdir):
@ -13,3 +14,17 @@ def test_legacy_api(tmpdir):
style_guide = legacy.get_style_guide()
report = style_guide.check_files([t_py.strpath])
assert report.total_errors == 1
def test_legacy_api_uses_initialized_options_for_parallel_checks(tmpdir):
with tmpdir.as_cwd():
a_py = tmpdir.join("a.py")
b_py = tmpdir.join("b.py")
a_py.write('x = "' + "a" * 80 + '"\n')
b_py.write('y = "' + "b" * 80 + '"\n')
style_guide = legacy.get_style_guide(color="never", max_line_length=88)
style_guide.options.jobs = JobsArgument("2")
report = style_guide.check_files([a_py.strpath, b_py.strpath])
assert report.total_errors == 0