Skip to content

Commit ea13283

Browse files
committed
Refactor plugin to group patches and augmentations
1 parent b915532 commit ea13283

14 files changed

+402
-335
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
### Added
55
- Suppressing FP `no-member` from [using workaround of accessing cls in setup fixture](https://github.com/pytest-dev/pytest/issues/3778#issuecomment-411899446)
66

7+
### Changed
8+
- Refactor plugin to group patches and augmentations
9+
710
## [0.1.2] - 2020-05-22
811
### Fixed
912
- Fix fixtures defined with `@pytest.yield_fixture` decorator still showing FP

pylint_pytest.py

Lines changed: 0 additions & 305 deletions
This file was deleted.

pylint_pytest/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os
2+
import sys
3+
import inspect
4+
import importlib
5+
import glob
6+
7+
from .checkers import BasePytestChecker
8+
9+
10+
# pylint: disable=protected-access
11+
def register(linter):
12+
'''auto discover pylint checker classes'''
13+
dirname = os.path.dirname(__file__)
14+
for module in glob.glob(os.path.join(dirname, 'checkers', '*.py')):
15+
# trim file extension
16+
module = os.path.splitext(module)[0]
17+
18+
# use relative path only
19+
module = module.replace(dirname, '', 1)
20+
21+
# translate file path into module import path
22+
module = module.replace('/', '.')
23+
24+
checker = importlib.import_module(module, package=os.path.basename(dirname))
25+
for attr_name in dir(checker):
26+
attr_val = getattr(checker, attr_name)
27+
if attr_val != BasePytestChecker and \
28+
inspect.isclass(attr_val) and \
29+
issubclass(attr_val, BasePytestChecker):
30+
linter.register_checker(attr_val(linter))

pylint_pytest/checkers/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from pylint.checkers import BaseChecker
2+
3+
4+
class BasePytestChecker(BaseChecker):
5+
name = 'pylint-pytest'

0 commit comments

Comments
 (0)