Skip to content

Commit 05dd345

Browse files
committed
Fix typing
1 parent 1cafa16 commit 05dd345

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/pip/_internal/cli/parser.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import textwrap
1010
from collections.abc import Generator
1111
from contextlib import suppress
12-
from typing import IO, Any, Dict, List, NoReturn, Optional
12+
from typing import IO, Any, NoReturn
1313

1414
from pip._vendor.rich.console import Console, RenderableType, detect_legacy_windows
1515
from pip._vendor.rich.markup import escape
@@ -27,15 +27,15 @@
2727
class PrettyHelpFormatter(optparse.IndentedHelpFormatter):
2828
"""A prettier/less verbose help formatter for optparse."""
2929

30-
styles: Dict[str, StyleType] = {
30+
styles: dict[str, StyleType] = {
3131
"optparse.args": "cyan",
3232
"optparse.groups": "dark_orange",
3333
"optparse.help": "default",
3434
"optparse.metavar": "dark_cyan",
3535
"optparse.syntax": "bold",
3636
"optparse.text": "default",
3737
}
38-
highlights: List[str] = [
38+
highlights: list[str] = [
3939
r"(?:^|\s)(?P<args>-{1,2}[\w]+[\w-]*)", # highlight --words-with-dashes as args
4040
r"`(?P<syntax>[^`]*)`", # highlight `text in backquotes` as syntax
4141
]
@@ -47,7 +47,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
4747
kwargs["width"] = shutil.get_terminal_size()[0] - 2
4848
super().__init__(*args, **kwargs)
4949
self.console: Console = Console(theme=Theme(self.styles))
50-
self.rich_option_strings: Dict[optparse.Option, Text] = {}
50+
self.rich_option_strings: dict[optparse.Option, Text] = {}
5151

5252
def stringify(self, text: RenderableType) -> str:
5353
"""Render a rich object as a string."""
@@ -118,7 +118,7 @@ def rich_expand_default(self, option: optparse.Option) -> Text:
118118

119119
def format_option(self, option: optparse.Option) -> str:
120120
# Overridden to call the rich methods.
121-
result: List[Text] = []
121+
result: list[Text] = []
122122
opts = self.rich_option_strings[option]
123123
opt_width = self.help_position - self.current_indent - 2
124124
if len(opts) > opt_width:
@@ -169,7 +169,7 @@ def store_option_strings(self, parser: optparse.OptionParser) -> None:
169169

170170
def rich_format_option_strings(self, option: optparse.Option) -> Text:
171171
# `HelpFormatter.format_option_strings()` equivalent that returns a `Text`.
172-
opts: List[Text] = []
172+
opts: list[Text] = []
173173

174174
if option._short_opts:
175175
opts.append(Text(option._short_opts[0], "optparse.args"))
@@ -244,7 +244,7 @@ def option_list_all(self) -> list[optparse.Option]:
244244

245245
return res
246246

247-
def _print_ansi(self, text: str, file: Optional[IO[str]] = None) -> None:
247+
def _print_ansi(self, text: str, file: IO[str] | None = None) -> None:
248248
if file is None:
249249
file = sys.stdout
250250
if detect_legacy_windows():
@@ -253,11 +253,11 @@ def _print_ansi(self, text: str, file: Optional[IO[str]] = None) -> None:
253253
else:
254254
file.write(text)
255255

256-
def print_usage(self, file: Optional[IO[str]] = None) -> None:
256+
def print_usage(self, file: IO[str] | None = None) -> None:
257257
if self.usage:
258258
self._print_ansi(self.get_usage(), file=file)
259259

260-
def print_help(self, file: Optional[IO[str]] = None) -> None:
260+
def print_help(self, file: IO[str] | None = None) -> None:
261261
self._print_ansi(self.format_help(), file=file)
262262

263263

0 commit comments

Comments
 (0)