mirror of
https://fuchsia.googlesource.com/third_party/github.com/pylint-dev/pylint
synced 2024-09-20 23:51:39 +00:00
[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.
This commit is contained in:
parent
35579eba2e
commit
60a2db21d8
|
@ -7,9 +7,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import warnings
|
||||
from collections import namedtuple
|
||||
from tokenize import TokenInfo
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, NamedTuple
|
||||
|
||||
from astroid import nodes
|
||||
|
||||
|
@ -33,7 +32,12 @@ __all__ = (
|
|||
"CONFIDENCE_LEVEL_NAMES",
|
||||
)
|
||||
|
||||
Confidence = namedtuple("Confidence", ["name", "description"])
|
||||
|
||||
class Confidence(NamedTuple):
|
||||
name: str
|
||||
description: str
|
||||
|
||||
|
||||
# Warning Certainties
|
||||
HIGH = Confidence("HIGH", "Warning that is not based on inference result.")
|
||||
CONTROL_FLOW = Confidence(
|
||||
|
|
|
@ -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"))
|
||||
|
|
Loading…
Reference in New Issue
Block a user