summaryrefslogtreecommitdiff
path: root/pylint/utils
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2022-11-05 19:37:01 +0100
committerGitHub <noreply@github.com>2022-11-05 19:37:01 +0100
commit60a2db21d8ff6ca59e32f632ca501305c0403fe5 (patch)
treef2e5e156c5e5016e03e0819c8f1f3870c144637d /pylint/utils
parent35579eba2e5aa777151e19a95fb44f7071395788 (diff)
downloadpylint-git-60a2db21d8ff6ca59e32f632ca501305c0403fe5.tar.gz
[refactor] Use typed NamedTuple for Confidence + PragmaRepresenter (#7718)
The init needs to analyse a string with the old way of doing things, which is not the best in term of performance. We also have the benefit of being able to add typing with the new way of doing it.
Diffstat (limited to 'pylint/utils')
-rw-r--r--pylint/utils/pragma_parser.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py
index 8e34fa693..df3627380 100644
--- a/pylint/utils/pragma_parser.py
+++ b/pylint/utils/pragma_parser.py
@@ -5,8 +5,8 @@
from __future__ import annotations
import re
-from collections import namedtuple
from collections.abc import Generator
+from typing import NamedTuple
# Allow stopping after the first semicolon/hash encountered,
# so that an option can be continued with the reasons
@@ -27,7 +27,9 @@ OPTION_RGX = r"""
OPTION_PO = re.compile(OPTION_RGX, re.VERBOSE)
-PragmaRepresenter = namedtuple("PragmaRepresenter", "action messages")
+class PragmaRepresenter(NamedTuple):
+ action: str
+ messages: list[str]
ATOMIC_KEYWORDS = frozenset(("disable-all", "skip-file"))