Skip to content

Commit 7c21db2

Browse files
committed
Add ruff per-file-ignores
1 parent d5a6605 commit 7c21db2

File tree

7 files changed

+33
-24
lines changed

7 files changed

+33
-24
lines changed

.ruff.toml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,27 @@ exclude = [
77
"dist",
88
]
99
ignore = [
10-
"D", # pydocstyle
1110
"ANN", # flake8-annotations
1211
"ARG", # flake8-unused-arguments
1312
"BLE", # flake8-blind-except
14-
"C90", # mccabe
13+
"COM", # flake8-comma
14+
"D", # pydocstyle
1515
"EM", # flake8-errmsg
1616
"FBT", # flake8-boolean-trap
1717
"INP", # flake8-no-pep420
18-
"PLR", # Pylint Refactor
18+
"PLR0133", # Pylint Refactor
19+
"PLR2004",
1920
"PLW", # Pylint Warning
21+
"PTH", # flake8-use-pathlib
2022
"Q", # flake8-quotes
2123
"RET", # flake8-return
24+
"S101", # flake8-bandit assert
25+
"S102", # flake8-bandit exec
26+
"S110", # flake8-bandit try-except-pass
2227
"SIM102", # flake8-simplify collapsible-if
2328
"SIM105", # flake8-simplify use-contextlib-suppress
2429
"SLF", # flake8-self
2530
"T20", # flake8-print
26-
"S101", # flake8-bandit assert
27-
"S102", # flake8-bandit exec
28-
"S110", # flake8-bandit try-except-pass
2931
"TRY", # tryceratops
3032
]
3133
line-length = 140
@@ -38,3 +40,16 @@ target-version = "py37"
3840
force-single-line = true
3941
forced-separate = ["test_pytest_cov"]
4042
known-first-party = ["pytest_cov"]
43+
44+
[mccabe]
45+
max-complexity = 12
46+
47+
[per-file-ignores]
48+
"ci/bootstrap.py" = ["S701"]
49+
"docs/conf.py" = ["A001"]
50+
"src/pytest_cov/plugin.py" = ["B904", "PT004"]
51+
"tests/test_pytest_cov.py" = ["N801", "PT004", "RSE102", "SIM117"]
52+
53+
[pylint]
54+
max-args = 8
55+
max-branches = 13

examples/adhoc-layout/tests/test_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
def test_add():
55
assert example.add(1, 1) == 2
6-
assert not example.add(0, 1) == 2
6+
assert example.add(0, 1) != 2

examples/src-layout/tests/test_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
def test_add():
55
assert example.add(1, 1) == 2
6-
assert not example.add(0, 1) == 2
6+
assert example.add(0, 1) != 2

src/pytest_cov/embed.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ def init():
3838
import coverage
3939

4040
# Determine all source roots.
41-
if cov_source in os.pathsep:
42-
cov_source = None
43-
else:
44-
cov_source = cov_source.split(os.pathsep)
41+
cov_source = None if cov_source in os.pathsep else cov_source.split(os.pathsep)
4542
if cov_config == os.pathsep:
4643
cov_config = True
4744

@@ -108,7 +105,7 @@ def _signal_cleanup_handler(signum, frame):
108105
elif signum == signal.SIGTERM:
109106
os._exit(128 + signum)
110107
elif signum == signal.SIGINT:
111-
raise KeyboardInterrupt()
108+
raise KeyboardInterrupt
112109

113110

114111
def cleanup_on_signal(signum):

src/pytest_cov/engine.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,5 +412,3 @@ def finish(self):
412412

413413
def summary(self, stream):
414414
"""Only the master reports so do nothing."""
415-
416-
pass

src/pytest_cov/plugin.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def validate_report(arg):
3535
all_choices = term_choices + file_choices
3636
values = arg.split(":", 1)
3737
report_type = values[0]
38-
if report_type not in all_choices + ['']:
38+
if report_type not in [*all_choices, '']:
3939
msg = f'invalid choice: "{arg}" (choose from "{all_choices}")'
4040
raise argparse.ArgumentTypeError(msg)
4141

@@ -247,7 +247,7 @@ def pytest_sessionstart(self, session):
247247
self.pid = os.getpid()
248248
if self._is_worker(session):
249249
nodeid = (
250-
session.config.workerinput.get('workerid', getattr(session, 'nodeid'))
250+
session.config.workerinput.get('workerid', session.nodeid)
251251
)
252252
self.start(engine.DistWorker, session.config, nodeid)
253253
elif not self._started:
@@ -389,13 +389,12 @@ def switch_context(self, item, when):
389389
os.environ['COV_CORE_CONTEXT'] = context
390390

391391

392-
@pytest.fixture
392+
@pytest.fixture()
393393
def no_cover():
394394
"""A pytest fixture to disable coverage."""
395-
pass
396395

397396

398-
@pytest.fixture
397+
@pytest.fixture()
399398
def cov(request):
400399
"""A pytest fixture to provide access to the underlying coverage object."""
401400

tests/contextful.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_04(self):
3939
assert self.items[0] == "hello" # r4
4040

4141

42-
@pytest.fixture
42+
@pytest.fixture()
4343
def some_data():
4444
return [1, 2, 3] # s5 s6
4545

@@ -48,7 +48,7 @@ def test_05(some_data):
4848
assert len(some_data) == 3 # r5
4949

5050

51-
@pytest.fixture
51+
@pytest.fixture()
5252
def more_data(some_data):
5353
return [2*x for x in some_data] # s6
5454

@@ -83,15 +83,15 @@ def test_10():
8383
assert 1 == 1 # r10
8484

8585

86-
@pytest.mark.parametrize("x, ans", [
86+
@pytest.mark.parametrize(("x", "ans"), [
8787
(1, 101),
8888
(2, 202),
8989
])
9090
def test_11(x, ans):
9191
assert 100 * x + x == ans # r11-1 r11-2
9292

9393

94-
@pytest.mark.parametrize("x, ans", [
94+
@pytest.mark.parametrize(("x", "ans"), [
9595
(1, 101),
9696
(2, 202),
9797
], ids=['one', 'two'])

0 commit comments

Comments
 (0)