44import pathlib
55import re
66import sys
7+ from collections .abc import Iterable , Iterator
78from textwrap import dedent
8- from typing import Dict , Iterable , Iterator , List , Optional , Union
9+ from typing import Optional , Union
910
1011from docutils import nodes , statemachine
1112from docutils .parsers import rst
@@ -24,7 +25,7 @@ def convert_cli_option_to_envvar(opt_name: str) -> str:
2425 return f"PIP_{ normalized_opt_name } "
2526
2627
27- def convert_cli_opt_names_to_envvars (original_cli_opt_names : List [str ]) -> List [str ]:
28+ def convert_cli_opt_names_to_envvars (original_cli_opt_names : list [str ]) -> list [str ]:
2829 return [
2930 convert_cli_option_to_envvar (opt_name ) for opt_name in original_cli_opt_names
3031 ]
@@ -69,7 +70,7 @@ def _iter_lines_with_refs(self, lines: Iterable[str]) -> Iterator[str]:
6970 if prev is not None :
7071 yield prev
7172
72- def run (self ) -> List [nodes .Node ]:
73+ def run (self ) -> list [nodes .Node ]:
7374 source = self .state_machine .input_lines .source (
7475 self .lineno - self .state_machine .input_offset - 1 ,
7576 )
@@ -90,7 +91,7 @@ class PipCommandUsage(rst.Directive):
9091 required_arguments = 1
9192 optional_arguments = 3
9293
93- def run (self ) -> List [nodes .Node ]:
94+ def run (self ) -> list [nodes .Node ]:
9495 cmd = create_command (self .arguments [0 ])
9596 cmd_prefix = "python -m pip"
9697 if len (self .arguments ) > 1 :
@@ -105,7 +106,7 @@ def run(self) -> List[nodes.Node]:
105106class PipCommandDescription (rst .Directive ):
106107 required_arguments = 1
107108
108- def run (self ) -> List [nodes .Node ]:
109+ def run (self ) -> list [nodes .Node ]:
109110 node = nodes .paragraph ()
110111 node .document = self .state .document
111112 desc = ViewList ()
@@ -121,7 +122,7 @@ def run(self) -> List[nodes.Node]:
121122class PipOptions (rst .Directive ):
122123 def _format_option (
123124 self , option : optparse .Option , cmd_name : Optional [str ] = None
124- ) -> List [str ]:
125+ ) -> list [str ]:
125126 bookmark_line = (
126127 f".. _`{ cmd_name } _{ option ._long_opts [0 ]} `:"
127128 if cmd_name
@@ -165,7 +166,7 @@ def _format_options(
165166 for line in self ._format_option (option , cmd_name ):
166167 self .view_list .append (line , "" )
167168
168- def run (self ) -> List [nodes .Node ]:
169+ def run (self ) -> list [nodes .Node ]:
169170 node = nodes .paragraph ()
170171 node .document = self .state .document
171172 self .view_list = ViewList ()
@@ -242,7 +243,7 @@ class PipCLIDirective(rst.Directive):
242243 has_content = True
243244 optional_arguments = 1
244245
245- def run (self ) -> List [nodes .Node ]:
246+ def run (self ) -> list [nodes .Node ]:
246247 node = nodes .paragraph ()
247248 node .document = self .state .document
248249
@@ -310,7 +311,7 @@ def run(self) -> List[nodes.Node]:
310311 return [node ]
311312
312313
313- def setup (app : Sphinx ) -> Dict [str , Union [bool , str ]]:
314+ def setup (app : Sphinx ) -> dict [str , Union [bool , str ]]:
314315 app .add_directive ("pip-command-usage" , PipCommandUsage )
315316 app .add_directive ("pip-command-description" , PipCommandDescription )
316317 app .add_directive ("pip-command-options" , PipCommandOptions )
0 commit comments