Skip to content

Commit 9fada6b

Browse files
committed
pre-commit run -a
Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
1 parent 22b848e commit 9fada6b

35 files changed

+367
-279
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A clear and concise description of what the bug is.
1212

1313
**To Reproduce**
1414
Package versions
15-
- pylint
15+
- pylint
1616
- pytest
1717
- pylint-pytest
1818

.pre-commit-config.yaml

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.5.0
44
hooks:
55
- id: end-of-file-fixer
66
exclude: ^.idea/
77
- id: trailing-whitespace
88
- id: pretty-format-json
99
args: [ "--no-sort-keys", "--autofix", "--indent=4" ]
1010
exclude: ^.vscode/
11-
- repo: https://github.com/asottile/pyupgrade
12-
rev: v3.13.0
13-
hooks:
14-
- id: pyupgrade
15-
args:
16-
- --py36-plus
11+
# - repo: https://github.com/asottile/pyupgrade
12+
# rev: v3.13.0
13+
# hooks:
14+
# - id: pyupgrade
15+
# args:
16+
# - --py36-plus
1717
- repo: https://github.com/PyCQA/autoflake
1818
rev: v2.2.1
1919
hooks:
2020
- id: autoflake
21-
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.0.285
23-
hooks:
24-
- id: ruff
21+
# - repo: https://github.com/astral-sh/ruff-pre-commit
22+
# rev: v0.0.292
23+
# hooks:
24+
# - id: ruff
2525
- repo: https://github.com/pycqa/isort
2626
rev: 5.12.0
2727
hooks:
@@ -52,34 +52,34 @@ repos:
5252
- id: rst-directive-colons
5353
- id: rst-inline-touching-normal
5454
- id: text-unicode-replacement-char
55-
- repo: https://github.com/pycqa/flake8
56-
rev: 5.0.4
57-
hooks:
58-
- id: flake8
59-
additional_dependencies:
60-
- flake8-bandit
61-
- flake8-bugbear
62-
- flake8-class-attributes-order
63-
- flake8-comprehensions
64-
# - flake8-docstrings # it is a mess to clean up; let's only warn user's IDEs instead.
65-
- flake8-future-annotations
66-
- flake8-noqa
67-
- flake8-print
68-
- flake8-pyproject
69-
- flake8-pytest-style
70-
- flake8-type-checking
71-
- flake8-variables-names
72-
- pep8-naming
73-
- repo: https://github.com/pre-commit/mirrors-mypy
74-
rev: v1.6.0
75-
hooks:
76-
- id: mypy
77-
- repo: local
78-
hooks:
79-
- id: pylint
80-
name: pylint
81-
entry: bash -c 'test -d .venv && . .venv/bin/activate ; pylint ${CI:+--reports=yes} "$@"' -
82-
language: system
83-
types: [ python ]
84-
args:
85-
- --disable=R,C
55+
# - repo: https://github.com/pycqa/flake8
56+
# rev: 5.0.4
57+
# hooks:
58+
# - id: flake8
59+
# additional_dependencies:
60+
# - flake8-bandit
61+
# - flake8-bugbear
62+
# - flake8-class-attributes-order
63+
# - flake8-comprehensions
64+
# # - flake8-docstrings # it is a mess to clean up; let's only warn user's IDEs instead.
65+
# - flake8-future-annotations
66+
# - flake8-noqa
67+
# - flake8-print
68+
# - flake8-pyproject
69+
# - flake8-pytest-style
70+
# - flake8-type-checking
71+
# - flake8-variables-names
72+
# - pep8-naming
73+
# - repo: https://github.com/pre-commit/mirrors-mypy
74+
# rev: v1.6.0
75+
# hooks:
76+
# - id: mypy
77+
# - repo: local
78+
# hooks:
79+
# - id: pylint
80+
# name: pylint
81+
# entry: bash -c 'test -d .venv && . .venv/bin/activate ; pylint ${CI:+--reports=yes} "$@"' -
82+
# language: system
83+
# types: [ python ]
84+
# args:
85+
# - --disable=R,C

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def test_something(conftest_fixture): # <- Unused argument 'conftest_fixture'
5151
FP when an imported fixture is used in an applicable function, e.g.
5252

5353
```python
54-
from fixture_collections import imported_fixture # <- Unused imported_fixture imported from fixture_collections
54+
from fixture_collections import (
55+
imported_fixture,
56+
) # <- Unused imported_fixture imported from fixture_collections
57+
5558

5659
def test_something(imported_fixture):
5760
...
@@ -64,7 +67,10 @@ FP when an imported/declared fixture is used in an applicable function, e.g.
6467
```python
6568
from fixture_collections import imported_fixture
6669

67-
def test_something(imported_fixture): # <- Redefining name 'imported_fixture' from outer scope (line 1)
70+
71+
def test_something(
72+
imported_fixture,
73+
): # <- Redefining name 'imported_fixture' from outer scope (line 1)
6874
...
6975
```
7076

@@ -75,15 +81,18 @@ FP when class attributes are defined in setup fixtures
7581
```python
7682
import pytest
7783

84+
7885
class TestClass(object):
7986
@staticmethod
80-
@pytest.fixture(scope='class', autouse=True)
87+
@pytest.fixture(scope="class", autouse=True)
8188
def setup_class(request):
8289
cls = request.cls
8390
cls.defined_in_setup_class = True
8491

8592
def test_foo(self):
86-
assert self.defined_in_setup_class # <- Instance of 'TestClass' has no 'defined_in_setup_class' member
93+
assert (
94+
self.defined_in_setup_class
95+
) # <- Instance of 'TestClass' has no 'defined_in_setup_class' member
8796
```
8897

8998
## Raise new warning(s)
@@ -95,6 +104,7 @@ Raise when using deprecated `@pytest.yield_fixture` decorator ([ref](https://doc
95104
```python
96105
import pytest
97106

107+
98108
@pytest.yield_fixture # <- Using a deprecated @pytest.yield_fixture decorator
99109
def yield_fixture():
100110
yield
@@ -107,12 +117,16 @@ Raise when using every `@pytest.mark.*` for the fixture ([ref](https://docs.pyte
107117
```python
108118
import pytest
109119

120+
110121
@pytest.fixture
111122
def awesome_fixture():
112123
...
113124

125+
114126
@pytest.fixture
115-
@pytest.mark.usefixtures("awesome_fixture") # <- Using useless `@pytest.mark.*` decorator for fixtures
127+
@pytest.mark.usefixtures(
128+
"awesome_fixture"
129+
) # <- Using useless `@pytest.mark.*` decorator for fixtures
116130
def another_awesome_fixture():
117131
...
118132
```
@@ -124,6 +138,7 @@ Raise when using deprecated positional arguments for fixture decorator ([ref](ht
124138
```python
125139
import pytest
126140

141+
127142
@pytest.fixture("module") # <- Using a deprecated positional arguments for fixture
128143
def awesome_fixture():
129144
...

pylint_pytest/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
import os
2-
import inspect
3-
import importlib
41
import glob
2+
import importlib
3+
import inspect
4+
import os
55

66
from .checkers import BasePytestChecker
77

88

99
# pylint: disable=protected-access
1010
def register(linter):
11-
'''auto discover pylint checker classes'''
11+
"""auto discover pylint checker classes"""
1212
dirname = os.path.dirname(__file__)
13-
for module in glob.glob(os.path.join(dirname, 'checkers', '*.py')):
13+
for module in glob.glob(os.path.join(dirname, "checkers", "*.py")):
1414
# trim file extension
1515
module = os.path.splitext(module)[0]
1616

1717
# use relative path only
18-
module = module.replace(dirname, '', 1)
18+
module = module.replace(dirname, "", 1)
1919

2020
# translate file path into module import path
21-
module = module.replace(os.sep, '.')
21+
module = module.replace(os.sep, ".")
2222

2323
checker = importlib.import_module(module, package=os.path.basename(dirname))
2424
for attr_name in dir(checker):
2525
attr_val = getattr(checker, attr_name)
26-
if attr_val != BasePytestChecker and \
27-
inspect.isclass(attr_val) and \
28-
issubclass(attr_val, BasePytestChecker):
26+
if (
27+
attr_val != BasePytestChecker
28+
and inspect.isclass(attr_val)
29+
and issubclass(attr_val, BasePytestChecker)
30+
):
2931
linter.register_checker(attr_val(linter))

pylint_pytest/checkers/__init__.py

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

33

44
class BasePytestChecker(BaseChecker):
5-
name = 'pylint-pytest'
5+
name = "pylint-pytest"

pylint_pytest/checkers/class_attr_loader.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import astroid
22
from pylint.interfaces import IAstroidChecker
3+
34
from ..utils import _can_use_fixture, _is_class_autouse_fixture
45
from . import BasePytestChecker
56

67

78
class ClassAttrLoader(BasePytestChecker):
89
__implements__ = IAstroidChecker
9-
msgs = {'E6400': ('', 'pytest-class-attr-loader', '')}
10+
msgs = {"E6400": ("", "pytest-class-attr-loader", "")}
1011

1112
in_setup = False
1213
request_cls = set()
1314
class_node = None
1415

1516
def visit_functiondef(self, node):
16-
'''determine if a method is a class setup method'''
17+
"""determine if a method is a class setup method"""
1718
self.in_setup = False
1819
self.request_cls = set()
1920
self.class_node = None
@@ -23,17 +24,23 @@ def visit_functiondef(self, node):
2324
self.class_node = node.parent
2425

2526
def visit_assign(self, node):
26-
'''store the aliases for `cls`'''
27-
if self.in_setup and isinstance(node.value, astroid.Attribute) and \
28-
node.value.attrname == 'cls' and \
29-
node.value.expr.name == 'request':
27+
"""store the aliases for `cls`"""
28+
if (
29+
self.in_setup
30+
and isinstance(node.value, astroid.Attribute)
31+
and node.value.attrname == "cls"
32+
and node.value.expr.name == "request"
33+
):
3034
# storing the aliases for cls from request.cls
3135
self.request_cls = set(map(lambda t: t.name, node.targets))
3236

3337
def visit_assignattr(self, node):
34-
if self.in_setup and isinstance(node.expr, astroid.Name) and \
35-
node.expr.name in self.request_cls and \
36-
node.attrname not in self.class_node.locals:
38+
if (
39+
self.in_setup
40+
and isinstance(node.expr, astroid.Name)
41+
and node.expr.name in self.request_cls
42+
and node.attrname not in self.class_node.locals
43+
):
3744
try:
3845
# find Assign node which contains the source "value"
3946
assign_node = node

0 commit comments

Comments
 (0)