diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-09-15 20:42:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-15 20:42:22 +0200 |
commit | 22e56c07cf745d695df1d52fe3988cc071f0951b (patch) | |
tree | 713b888a2f24239932b7d8a6a1d9f8bffe0026cd /pylint/checkers/similar.py | |
parent | cb896128b0e8f62c0650e980ef77a3c8af21ef8d (diff) | |
download | pylint-git-22e56c07cf745d695df1d52fe3988cc071f0951b.tar.gz |
Add typing to all calls to ``self.stats`` (#4973)
* Add typing to all calls to ``self.stats``
All checkers inherit from a baseclass which has a ``stats`` attribute.
This attribute has a fairly unmanageable type, but the current typing includes all variations of the attribute.
Other changes not directly related to ``self.stats`` are due to ``mypy``warnings.
This incorporate the feedback received in #4954
* Add ``CheckerStatistic`` class to ``pylint/typing``
* Guard `typing.Counter` import
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'pylint/checkers/similar.py')
-rw-r--r-- | pylint/checkers/similar.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py index 4ceb5d660..2a28e7d6c 100644 --- a/pylint/checkers/similar.py +++ b/pylint/checkers/similar.py @@ -73,6 +73,7 @@ from astroid import nodes from pylint.checkers import BaseChecker, MapReduceMixin, table_lines_from_stats from pylint.interfaces import IRawChecker from pylint.reporters.ureports.nodes import Table +from pylint.typing import CheckerStats from pylint.utils import decoding_stream DEFAULT_MIN_SIMILARITY_LINE = 4 @@ -721,7 +722,11 @@ MSGS = { } -def report_similarities(sect, stats, old_stats): +def report_similarities( + sect, + stats: CheckerStats, + old_stats: CheckerStats, +): """make a layout with some stats about duplication""" lines = ["", "now", "previous", "difference"] lines += table_lines_from_stats( @@ -804,7 +809,7 @@ class SimilarChecker(BaseChecker, Similar, MapReduceMixin): ignore_imports=self.config.ignore_imports, ignore_signatures=self.config.ignore_signatures, ) - self.stats = None + self.stats: CheckerStats = {} def set_option(self, optname, value, action=None, optdict=None): """method called to set an option (registered in the options list) |