Skip to content

Commit 9b08c03

Browse files
authored
Merge pull request #720 from pytest-dev/linters
Add flake8 linters
2 parents 18de3a8 + 79abaa4 commit 9b08c03

File tree

8 files changed

+21
-17
lines changed

8 files changed

+21
-17
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ repos:
2323
hooks:
2424
- id: pyupgrade
2525
args: ["--py39-plus"]
26-
# TODO: Enable mypy checker when the checks succeed
27-
#- repo: https://github.com/pre-commit/mirrors-mypy
28-
# rev: v0.931
29-
# hooks:
30-
# - id: mypy
31-
# additional_dependencies: [types-setuptools]
26+
- repo: https://github.com/pycqa/flake8
27+
rev: "7.1.1"
28+
hooks:
29+
- id: flake8
30+
additional_dependencies: [
31+
"flake8-pyproject",
32+
"flake8-bugbear",
33+
]

docs/conf.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
sys.path.insert(0, os.path.abspath(".."))
2222

23-
import pytest_bdd
24-
2523
# -- General configuration -----------------------------------------------------
2624

2725
# If your documentation needs a minimal Sphinx version, state it here.
@@ -175,11 +173,11 @@
175173

176174
latex_elements = {
177175
# The paper size ('letterpaper' or 'a4paper').
178-
#'papersize': 'letterpaper',
176+
# 'papersize': 'letterpaper',
179177
# The font size ('10pt', '11pt' or '12pt').
180-
#'pointsize': '10pt',
178+
# 'pointsize': '10pt',
181179
# Additional stuff for the LaTeX preamble.
182-
#'preamble': '',
180+
# 'preamble': '',
183181
}
184182

185183
# Grouping the document tree into LaTeX files. List of tuples

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ build-backend = "poetry.core.masonry.api"
5959
line-length = 120
6060
target-version = ["py39", "py310", "py311", "py312"]
6161

62+
[tool.flake8]
63+
# E1: indentation: already covered by `black`
64+
# E2: whitespace: already covered by `black`
65+
# E3: blank line: already covered by `black`
66+
# E501: line length: already covered by `black`
67+
extend-ignore = "E1,E2,E3,E501"
68+
6269
[tool.isort]
6370
profile = "black"
6471
line_length = 120

src/pytest_bdd/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .gherkin_parser import Step as GherkinStep
1818
from .gherkin_parser import Tag as GherkinTag
1919
from .gherkin_parser import get_gherkin_document
20-
from .types import GIVEN, STEP_TYPES, THEN, WHEN
20+
from .types import STEP_TYPES
2121

2222
STEP_PARAM_RE = re.compile(r"<(.+?)>")
2323
COMMENT_RE = re.compile(r"(^|(?<=\s))#")

src/pytest_bdd/scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def find_fixturedefs_for_step(step: Step, fixturemanager: FixtureManager, node:
5151
# happens to be that _arg2fixturedefs is changed during the iteration so we use a copy
5252
fixture_def_by_name = list(fixturemanager._arg2fixturedefs.items())
5353
for fixturename, fixturedefs in fixture_def_by_name:
54-
for pos, fixturedef in enumerate(fixturedefs):
54+
for _, fixturedef in enumerate(fixturedefs):
5555
step_func_context = getattr(fixturedef.func, "_pytest_bdd_step_context", None)
5656
if step_func_context is None:
5757
continue

tests/datatable/test_datatable.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import textwrap
2-
from typing import List
32

43
from src.pytest_bdd.utils import collect_dumped_objects
54

tests/feature/test_cucumber_json.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from typing import TYPE_CHECKING, Any
99

1010
if TYPE_CHECKING:
11-
from typing import Optional
12-
1311
from _pytest.pytester import Pytester, RunResult
1412

1513

tests/steps/test_common.py

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

55
import pytest
66

7-
from pytest_bdd import given, parser, parsers, then, when
7+
from pytest_bdd import given, parsers, then, when
88
from pytest_bdd.utils import collect_dumped_objects
99

1010

0 commit comments

Comments
 (0)