-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
23 lines (19 loc) · 715 Bytes
/
conftest.py
File metadata and controls
23 lines (19 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Third party
from _pytest.config.argparsing import Parser
def pytest_addoption(parser: Parser) -> None:
parser.addoption(
"--lint-only",
action="store_true",
default=False,
help="Only run linting checks",
)
def pytest_collection_modifyitems(session, config, items) -> None:
"""Enhance pytest to allow for a linting only option"""
if config.getoption("--lint-only"):
lint_items = []
for linter in ["flake8", "black", "mypy", "mccabe"]:
if config.getoption(f"--{linter}"):
lint_items.extend(
[item for item in items if item.get_closest_marker(linter)]
)
items[:] = lint_items