Skip to content

Commit 2b1bbed

Browse files
ruff check pylint --fix --unsafe-fixes
1 parent 4976d7c commit 2b1bbed

File tree

20 files changed

+61
-82
lines changed

20 files changed

+61
-82
lines changed

doc/exts/pylint_messages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from inspect import getmodule
1313
from itertools import chain, groupby
1414
from pathlib import Path
15-
from typing import DefaultDict, Dict, List, NamedTuple, Tuple
15+
from typing import NamedTuple
1616

1717
from sphinx.application import Sphinx
1818

@@ -52,8 +52,8 @@ class ExampleType(str, Enum):
5252
BAD = "bad"
5353

5454

55-
MessagesDict = Dict[str, List[MessageData]]
56-
OldMessagesDict = Dict[str, DefaultDict[Tuple[str, str], List[Tuple[str, str]]]]
55+
MessagesDict = dict[str, list[MessageData]]
56+
OldMessagesDict = dict[str, defaultdict[tuple[str, str], list[tuple[str, str]]]]
5757
"""DefaultDict is indexed by tuples of (old name symbol, old name id) and values are
5858
tuples of (new name symbol, new name category).
5959
"""

doc/exts/pylint_options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from collections import defaultdict
1111
from inspect import getmodule
1212
from pathlib import Path
13-
from typing import Dict, List, NamedTuple
13+
from typing import NamedTuple
1414

1515
import tomlkit
1616
from sphinx.application import Sphinx
@@ -30,7 +30,7 @@ class OptionsData(NamedTuple):
3030
extension: bool
3131

3232

33-
OptionsDataDict = Dict[str, List[OptionsData]]
33+
OptionsDataDict = dict[str, list[OptionsData]]
3434

3535
PYLINT_BASE_PATH = Path(__file__).resolve().parent.parent.parent
3636
"""Base path to the project folder."""

pylint/checkers/base/name_checker/checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from collections.abc import Iterable
1515
from enum import Enum, auto
1616
from re import Pattern
17-
from typing import TYPE_CHECKING, Tuple
17+
from typing import TYPE_CHECKING
1818

1919
import astroid
2020
from astroid import nodes
@@ -34,7 +34,7 @@
3434
if TYPE_CHECKING:
3535
from pylint.lint.pylinter import PyLinter
3636

37-
_BadNamesTuple = Tuple[nodes.NodeNG, str, str, interfaces.Confidence]
37+
_BadNamesTuple = tuple[nodes.NodeNG, str, str, interfaces.Confidence]
3838

3939
# Default patterns for name types that do not have styles
4040
DEFAULT_PATTERNS = {

pylint/checkers/imports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from collections import defaultdict
1414
from collections.abc import ItemsView, Sequence
1515
from functools import cached_property
16-
from typing import TYPE_CHECKING, Any, Dict, List, Union
16+
from typing import TYPE_CHECKING, Any, Union
1717

1818
import astroid
1919
from astroid import nodes
@@ -43,7 +43,7 @@
4343

4444
# The dictionary with Any should actually be a _ImportTree again
4545
# but mypy doesn't support recursive types yet
46-
_ImportTree = Dict[str, Union[List[Dict[str, Any]], List[str]]]
46+
_ImportTree = dict[str, Union[list[dict[str, Any]], list[str]]]
4747

4848
DEPRECATED_MODULES = {
4949
(0, 0, 0): {"tkinter.tix", "fpectl"},

pylint/checkers/stdlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import sys
1010
from collections.abc import Iterable
11-
from typing import TYPE_CHECKING, Any, Dict, Set, Tuple
11+
from typing import TYPE_CHECKING, Any
1212

1313
import astroid
1414
from astroid import nodes, util
@@ -22,7 +22,7 @@
2222
if TYPE_CHECKING:
2323
from pylint.lint import PyLinter
2424

25-
DeprecationDict = Dict[Tuple[int, int, int], Set[str]]
25+
DeprecationDict = dict[tuple[int, int, int], set[str]]
2626

2727
OPEN_FILES_MODE = ("open", "file")
2828
OPEN_FILES_FUNCS = (*OPEN_FILES_MODE, "read_text", "write_text")

pylint/checkers/symilar.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,7 @@
4242
from getopt import GetoptError, getopt
4343
from io import BufferedIOBase, BufferedReader, BytesIO
4444
from itertools import chain
45-
from typing import (
46-
TYPE_CHECKING,
47-
Dict,
48-
List,
49-
NamedTuple,
50-
NewType,
51-
NoReturn,
52-
TextIO,
53-
Tuple,
54-
Union,
55-
)
45+
from typing import TYPE_CHECKING, NamedTuple, NewType, NoReturn, TextIO, Union
5646

5747
import astroid
5848
from astroid import nodes
@@ -84,10 +74,10 @@ class LineSpecifs(NamedTuple):
8474

8575
# Links LinesChunk object to the starting indices (in lineset's stripped lines)
8676
# of the different chunk of lines that are used to compute the hash
87-
HashToIndex_T = Dict["LinesChunk", List[Index]]
77+
HashToIndex_T = dict["LinesChunk", list[Index]]
8878

8979
# Links index in the lineset's stripped lines to the real lines in the file
90-
IndexToLines_T = Dict[Index, "SuccessiveLinesLimits"]
80+
IndexToLines_T = dict[Index, "SuccessiveLinesLimits"]
9181

9282
# The types the streams read by pylint can take. Originating from astroid.nodes.Module.stream() and open()
9383
STREAM_TYPES = Union[TextIO, BufferedReader, BytesIO]
@@ -113,7 +103,7 @@ def __init__(
113103

114104
# Links the indices to the starting line in both lineset's stripped lines to
115105
# the start and end lines in both files
116-
CplIndexToCplLines_T = Dict["LineSetStartCouple", CplSuccessiveLinesLimits]
106+
CplIndexToCplLines_T = dict["LineSetStartCouple", CplSuccessiveLinesLimits]
117107

118108

119109
class LinesChunk:
@@ -212,7 +202,7 @@ def increment(self, value: Index) -> LineSetStartCouple:
212202
)
213203

214204

215-
LinesChunkLimits_T = Tuple["LineSet", LineNumber, LineNumber]
205+
LinesChunkLimits_T = tuple["LineSet", LineNumber, LineNumber]
216206

217207

218208
def hash_lineset(

pylint/config/argument.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
import os
1414
import pathlib
1515
import re
16-
from collections.abc import Callable
16+
from collections.abc import Callable, Sequence
1717
from glob import glob
18-
from typing import Any, Literal, Pattern, Sequence, Tuple, Union
18+
from re import Pattern
19+
from typing import Any, Literal, Union
1920

2021
from pylint import interfaces
2122
from pylint import utils as pylint_utils
@@ -30,7 +31,7 @@
3031
Pattern[str],
3132
Sequence[str],
3233
Sequence[Pattern[str]],
33-
Tuple[int, ...],
34+
tuple[int, ...],
3435
]
3536
"""List of possible argument types."""
3637

pylint/config/config_file_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
import sys
1212
from pathlib import Path
13-
from typing import TYPE_CHECKING, Dict, List, Tuple
13+
from typing import TYPE_CHECKING
1414

1515
from pylint.config.utils import _parse_rich_type_value
1616

@@ -22,7 +22,7 @@
2222
if TYPE_CHECKING:
2323
from pylint.lint import PyLinter
2424

25-
PylintConfigFileData = Tuple[Dict[str, str], List[str]]
25+
PylintConfigFileData = tuple[dict[str, str], list[str]]
2626

2727

2828
class _RawConfParser:

pylint/extensions/code_style.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import annotations
66

77
import sys
8-
from typing import TYPE_CHECKING, Tuple, Type, cast
8+
from typing import TYPE_CHECKING, cast
99

1010
from astroid import nodes
1111

@@ -152,7 +152,7 @@ def _check_dict_consider_namedtuple_dataclass(self, node: nodes.Dict) -> None:
152152
if len(node.items) > 1 and all(
153153
isinstance(dict_value, nodes.Dict) for _, dict_value in node.items
154154
):
155-
KeyTupleT = Tuple[Type[nodes.NodeNG], str]
155+
KeyTupleT = tuple[type[nodes.NodeNG], str]
156156

157157
# Makes sure all keys are 'Const' string nodes
158158
keys_checked: set[KeyTupleT] = set()

pylint/message/_deleted_message_ids.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from __future__ import annotations
66

7-
from functools import lru_cache
7+
from functools import cache
88
from typing import NamedTuple
99

1010

@@ -131,7 +131,7 @@ class DeletedMessage(NamedTuple):
131131
}
132132

133133

134-
@lru_cache(maxsize=None)
134+
@cache
135135
def is_deleted_symbol(symbol: str) -> str | None:
136136
"""Return the explanation for removal if the message was removed."""
137137
for explanation, deleted_messages in DELETED_MESSAGES_IDS.items():
@@ -143,7 +143,7 @@ def is_deleted_symbol(symbol: str) -> str | None:
143143
return None
144144

145145

146-
@lru_cache(maxsize=None)
146+
@cache
147147
def is_deleted_msgid(msgid: str) -> str | None:
148148
"""Return the explanation for removal if the message was removed."""
149149
for explanation, deleted_messages in DELETED_MESSAGES_IDS.items():
@@ -155,7 +155,7 @@ def is_deleted_msgid(msgid: str) -> str | None:
155155
return None
156156

157157

158-
@lru_cache(maxsize=None)
158+
@cache
159159
def is_moved_symbol(symbol: str) -> str | None:
160160
"""Return the explanation for moving if the message was moved to extensions."""
161161
for explanation, moved_messages in MOVED_TO_EXTENSIONS.items():
@@ -167,7 +167,7 @@ def is_moved_symbol(symbol: str) -> str | None:
167167
return None
168168

169169

170-
@lru_cache(maxsize=None)
170+
@cache
171171
def is_moved_msgid(msgid: str) -> str | None:
172172
"""Return the explanation for moving if the message was moved to extensions."""
173173
for explanation, moved_messages in MOVED_TO_EXTENSIONS.items():

pylint/message/message_definition_store.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
from __future__ import annotations
66

77
import collections
8-
import functools
98
import sys
109
from collections.abc import Sequence, ValuesView
10+
from functools import cache
1111
from typing import TYPE_CHECKING
1212

1313
from pylint.exceptions import UnknownMessageError
@@ -58,9 +58,7 @@ def register_message(self, message: MessageDefinition) -> None:
5858
# and the arguments are relatively small we do not run the
5959
# risk of creating a large memory leak.
6060
# See discussion in: https://github.com/pylint-dev/pylint/pull/5673
61-
@functools.lru_cache( # pylint: disable=method-cache-max-size-none # noqa: B019
62-
maxsize=None
63-
)
61+
@cache # pylint: disable=method-cache-max-size-none # noqa: B019
6462
def get_message_definitions(self, msgid_or_symbol: str) -> list[MessageDefinition]:
6563
"""Returns the Message definition for either a numeric or symbolic id.
6664

pylint/pyreverse/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import shutil
1212
import subprocess
1313
import sys
14-
from typing import TYPE_CHECKING, Any, Callable, Optional, Tuple, Union
14+
from typing import TYPE_CHECKING, Any, Callable, Optional, Union
1515

1616
import astroid
1717
from astroid import nodes
@@ -22,9 +22,9 @@
2222

2323
_CallbackT = Callable[
2424
[nodes.NodeNG],
25-
Union[Tuple[ClassDiagram], Tuple[PackageDiagram, ClassDiagram], None],
25+
Union[tuple[ClassDiagram], tuple[PackageDiagram, ClassDiagram], None],
2626
]
27-
_CallbackTupleT = Tuple[Optional[_CallbackT], Optional[_CallbackT]]
27+
_CallbackTupleT = tuple[Optional[_CallbackT], Optional[_CallbackT]]
2828

2929

3030
RCFILE = ".pyreverserc"

pylint/reporters/reports_handler_mix_in.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import collections
88
from collections.abc import MutableSequence
9-
from typing import TYPE_CHECKING, DefaultDict, List, Tuple
9+
from typing import TYPE_CHECKING
1010

1111
from pylint.exceptions import EmptyReportError
1212
from pylint.reporters.ureports.nodes import Section
@@ -17,7 +17,9 @@
1717
from pylint.checkers import BaseChecker
1818
from pylint.lint.pylinter import PyLinter
1919

20-
ReportsDict = DefaultDict["BaseChecker", List[Tuple[str, str, ReportsCallable]]]
20+
ReportsDict = collections.defaultdict[
21+
"BaseChecker", list[tuple[str, str, ReportsCallable]]
22+
]
2123

2224

2325
class ReportsHandlerMixIn:

pylint/reporters/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import sys
1616
import warnings
1717
from dataclasses import asdict, fields
18-
from typing import TYPE_CHECKING, Dict, NamedTuple, TextIO
18+
from typing import TYPE_CHECKING, NamedTuple, TextIO
1919

2020
from pylint.message import Message
2121
from pylint.reporters import BaseReporter
@@ -65,7 +65,7 @@ def _colorize_ansi(self, msg: str) -> str:
6565
return msg
6666

6767

68-
ColorMappingDict = Dict[str, MessageStyle]
68+
ColorMappingDict = dict[str, MessageStyle]
6969

7070
TITLE_UNDERLINES = ["", "=", "-", "."]
7171

pylint/testutils/_primer/primer_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import abc
88
import argparse
99
from pathlib import Path
10-
from typing import Dict, TypedDict
10+
from typing import TypedDict
1111

1212
from pylint.reporters.json_reporter import OldJsonExport
1313
from pylint.testutils._primer import PackageToLint
@@ -18,7 +18,7 @@ class PackageData(TypedDict):
1818
messages: list[OldJsonExport]
1919

2020

21-
PackageMessages = Dict[str, PackageData]
21+
PackageMessages = dict[str, PackageData]
2222

2323

2424
class PrimerCommand:

pylint/testutils/configuration_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
import logging
1212
import unittest
1313
from pathlib import Path
14-
from typing import Any, Dict
14+
from typing import Any
1515

1616
from pylint.lint import Run
1717

1818
# We use Any in this typing because the configuration contains real objects and constants
1919
# that could be a lot of things.
2020
ConfigurationValue = Any
21-
PylintConfiguration = Dict[str, ConfigurationValue]
21+
PylintConfiguration = dict[str, ConfigurationValue]
2222

2323

2424
def get_expected_or_default(

0 commit comments

Comments
 (0)