@@ -49,8 +49,7 @@ class ConfigurationCommand(Command):
49
49
%prog [<file-option>] debug
50
50
"""
51
51
52
- def add_options (self ):
53
- # type: () -> None
52
+ def add_options (self ) -> None :
54
53
self .cmd_opts .add_option (
55
54
'--editor' ,
56
55
dest = 'editor' ,
@@ -88,8 +87,7 @@ def add_options(self):
88
87
89
88
self .parser .insert_option_group (0 , self .cmd_opts )
90
89
91
- def run (self , options , args ):
92
- # type: (Values, List[str]) -> int
90
+ def run (self , options : Values , args : List [str ]) -> int :
93
91
handlers = {
94
92
"list" : self .list_values ,
95
93
"edit" : self .open_in_editor ,
@@ -134,8 +132,7 @@ def run(self, options, args):
134
132
135
133
return SUCCESS
136
134
137
- def _determine_file (self , options , need_value ):
138
- # type: (Values, bool) -> Optional[Kind]
135
+ def _determine_file (self , options : Values , need_value : bool ) -> Optional [Kind ]:
139
136
file_options = [key for key , value in (
140
137
(kinds .USER , options .user_file ),
141
138
(kinds .GLOBAL , options .global_file ),
@@ -161,36 +158,31 @@ def _determine_file(self, options, need_value):
161
158
"(--user, --site, --global) to perform."
162
159
)
163
160
164
- def list_values (self , options , args ):
165
- # type: (Values, List[str]) -> None
161
+ def list_values (self , options : Values , args : List [str ]) -> None :
166
162
self ._get_n_args (args , "list" , n = 0 )
167
163
168
164
for key , value in sorted (self .configuration .items ()):
169
165
write_output ("%s=%r" , key , value )
170
166
171
- def get_name (self , options , args ):
172
- # type: (Values, List[str]) -> None
167
+ def get_name (self , options : Values , args : List [str ]) -> None :
173
168
key = self ._get_n_args (args , "get [name]" , n = 1 )
174
169
value = self .configuration .get_value (key )
175
170
176
171
write_output ("%s" , value )
177
172
178
- def set_name_value (self , options , args ):
179
- # type: (Values, List[str]) -> None
173
+ def set_name_value (self , options : Values , args : List [str ]) -> None :
180
174
key , value = self ._get_n_args (args , "set [name] [value]" , n = 2 )
181
175
self .configuration .set_value (key , value )
182
176
183
177
self ._save_configuration ()
184
178
185
- def unset_name (self , options , args ):
186
- # type: (Values, List[str]) -> None
179
+ def unset_name (self , options : Values , args : List [str ]) -> None :
187
180
key = self ._get_n_args (args , "unset [name]" , n = 1 )
188
181
self .configuration .unset_value (key )
189
182
190
183
self ._save_configuration ()
191
184
192
- def list_config_values (self , options , args ):
193
- # type: (Values, List[str]) -> None
185
+ def list_config_values (self , options : Values , args : List [str ]) -> None :
194
186
"""List config key-value pairs across different config files"""
195
187
self ._get_n_args (args , "debug" , n = 0 )
196
188
@@ -207,25 +199,22 @@ def list_config_values(self, options, args):
207
199
if file_exists :
208
200
self .print_config_file_values (variant )
209
201
210
- def print_config_file_values (self , variant ):
211
- # type: (Kind) -> None
202
+ def print_config_file_values (self , variant : Kind ) -> None :
212
203
"""Get key-value pairs from the file of a variant"""
213
204
for name , value in self .configuration .\
214
205
get_values_in_config (variant ).items ():
215
206
with indent_log ():
216
207
write_output ("%s: %s" , name , value )
217
208
218
- def print_env_var_values (self ):
219
- # type: () -> None
209
+ def print_env_var_values (self ) -> None :
220
210
"""Get key-values pairs present as environment variables"""
221
211
write_output ("%s:" , 'env_var' )
222
212
with indent_log ():
223
213
for key , value in sorted (self .configuration .get_environ_vars ()):
224
214
env_var = f'PIP_{ key .upper ()} '
225
215
write_output ("%s=%r" , env_var , value )
226
216
227
- def open_in_editor (self , options , args ):
228
- # type: (Values, List[str]) -> None
217
+ def open_in_editor (self , options : Values , args : List [str ]) -> None :
229
218
editor = self ._determine_editor (options )
230
219
231
220
fname = self .configuration .get_file_to_edit ()
@@ -240,8 +229,7 @@ def open_in_editor(self, options, args):
240
229
.format (e .returncode )
241
230
)
242
231
243
- def _get_n_args (self , args , example , n ):
244
- # type: (List[str], str, int) -> Any
232
+ def _get_n_args (self , args : List [str ], example : str , n : int ) -> Any :
245
233
"""Helper to make sure the command got the right number of arguments
246
234
"""
247
235
if len (args ) != n :
@@ -256,8 +244,7 @@ def _get_n_args(self, args, example, n):
256
244
else :
257
245
return args
258
246
259
- def _save_configuration (self ):
260
- # type: () -> None
247
+ def _save_configuration (self ) -> None :
261
248
# We successfully ran a modifying command. Need to save the
262
249
# configuration.
263
250
try :
@@ -268,8 +255,7 @@ def _save_configuration(self):
268
255
)
269
256
raise PipError ("Internal Error." )
270
257
271
- def _determine_editor (self , options ):
272
- # type: (Values) -> str
258
+ def _determine_editor (self , options : Values ) -> str :
273
259
if options .editor is not None :
274
260
return options .editor
275
261
elif "VISUAL" in os .environ :
0 commit comments