Skip to content

Commit f3cca6e

Browse files
authored
Add typing to two utility functions (#6111)
1 parent 06bc0a6 commit f3cca6e

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

pylint/config/argument.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010

1111
import re
12-
from typing import Callable, Dict, List, Optional, Pattern, Union
12+
from typing import Callable, Dict, List, Optional, Pattern, Sequence, Union
1313

1414
from pylint import utils as pylint_utils
1515

16-
_ArgumentTypes = Union[str, List[str], int, Pattern[str]]
16+
_ArgumentTypes = Union[str, Sequence[str], int, Pattern[str]]
1717
"""List of possible argument types."""
1818

1919

20-
def _csv_transformer(value: str) -> List[str]:
20+
def _csv_transformer(value: str) -> Sequence[str]:
2121
"""Transforms a comma separated string."""
2222
return pylint_utils._check_csv(value)
2323

pylint/reporters/text.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def colorize_ansi(
108108
def colorize_ansi(
109109
msg: str,
110110
msg_style: Optional[str] = None,
111-
style: Optional[str] = None,
111+
style: str = "",
112112
*,
113113
color: Optional[str] = None,
114114
) -> str:
@@ -119,7 +119,7 @@ def colorize_ansi(
119119
def colorize_ansi(
120120
msg: str,
121121
msg_style: Union[MessageStyle, str, None] = None,
122-
style: Optional[str] = None,
122+
style: str = "",
123123
**kwargs: Optional[str],
124124
) -> str:
125125
r"""colorize message by wrapping it with ansi escape codes
@@ -267,7 +267,7 @@ def __init__(
267267
def __init__(
268268
self,
269269
output: Optional[TextIO] = None,
270-
color_mapping: Optional[Dict[str, Tuple[Optional[str], Optional[str]]]] = None,
270+
color_mapping: Optional[Dict[str, Tuple[Optional[str], str]]] = None,
271271
) -> None:
272272
# Remove for pylint 3.0
273273
...
@@ -276,7 +276,7 @@ def __init__(
276276
self,
277277
output: Optional[TextIO] = None,
278278
color_mapping: Union[
279-
ColorMappingDict, Dict[str, Tuple[Optional[str], Optional[str]]], None
279+
ColorMappingDict, Dict[str, Tuple[Optional[str], str]], None
280280
] = None,
281281
) -> None:
282282
super().__init__(output)
@@ -292,7 +292,7 @@ def __init__(
292292
temp_color_mapping: ColorMappingDict = {}
293293
for key, value in color_mapping.items():
294294
color = value[0]
295-
style_attrs = tuple(_splitstrip(value[1]))
295+
style_attrs = tuple(_splitstrip(value[1])) # type: ignore[arg-type]
296296
temp_color_mapping[key] = MessageStyle(color, style_attrs)
297297
color_mapping = temp_color_mapping
298298
else:

pylint/utils/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
List,
2424
Optional,
2525
Pattern,
26+
Sequence,
2627
TextIO,
2728
Tuple,
2829
TypeVar,
@@ -276,7 +277,7 @@ def get_global_option(
276277
return default
277278

278279

279-
def _splitstrip(string, sep=","):
280+
def _splitstrip(string: str, sep: str = ",") -> List[str]:
280281
"""Return a list of stripped string by splitting the string given as
281282
argument on `sep` (',' by default), empty strings are discarded.
282283
@@ -314,7 +315,7 @@ def _unquote(string: str) -> str:
314315
return string
315316

316317

317-
def _check_csv(value):
318+
def _check_csv(value: Union[List[str], Tuple[str], str]) -> Sequence[str]:
318319
if isinstance(value, (list, tuple)):
319320
return value
320321
return _splitstrip(value)

0 commit comments

Comments
 (0)