Skip to content

Commit 43a1f76

Browse files
crevetorgvanrossum
authored andcommitted
Fix click annotation syntax and add missing keyword arguments to subprocess (new in 3.76) (#999)
* Fix click annotations * Add encoding and errors keyword arguments (new in 3.6)
1 parent b430318 commit 43a1f76

File tree

7 files changed

+207
-161
lines changed

7 files changed

+207
-161
lines changed

stdlib/3/subprocess.pyi

Lines changed: 87 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Stubs for subprocess
22

3-
# Based on http://docs.python.org/3.5/library/subprocess.html
3+
# Based on http://docs.python.org/3.6/library/subprocess.html
44
import sys
55
from typing import Sequence, Any, AnyStr, Mapping, Callable, Tuple, IO, Optional, Union, List, Type
66
from types import TracebackType
77

8-
98
if sys.version_info >= (3, 5):
109
class CompletedProcess:
1110
args = ... # type: Union[Sequence[str], str]
@@ -18,27 +17,52 @@ if sys.version_info >= (3, 5):
1817
stderr: Union[str, bytes, None] = ...) -> None: ...
1918
def check_returncode(self) -> None: ...
2019

21-
# Nearly same args as Popen.__init__ except for timeout, input, and check
22-
def run(args: Union[str, Sequence[str]],
23-
timeout: float = ...,
24-
input: Union[str, bytes] = ...,
25-
check: bool = ...,
26-
bufsize: int = ...,
27-
executable: str = ...,
28-
stdin: Any = ...,
29-
stdout: Any = ...,
30-
stderr: Any = ...,
31-
preexec_fn: Callable[[], Any] = ...,
32-
close_fds: bool = ...,
33-
shell: bool = ...,
34-
cwd: str = ...,
35-
env: Mapping[str, str] = ...,
36-
universal_newlines: bool = ...,
37-
startupinfo: Any = ...,
38-
creationflags: int = ...,
39-
restore_signals: bool = ...,
40-
start_new_session: bool = ...,
41-
pass_fds: Any = ...) -> CompletedProcess: ...
20+
if sys.version_info >= (3, 6):
21+
# Nearly same args as Popen.__init__ except for timeout, input, and check
22+
def run(args: Union[str, Sequence[str]],
23+
timeout: float = ...,
24+
input: Union[str, bytes] = ...,
25+
check: bool = ...,
26+
bufsize: int = ...,
27+
executable: str = ...,
28+
stdin: Any = ...,
29+
stdout: Any = ...,
30+
stderr: Any = ...,
31+
preexec_fn: Callable[[], Any] = ...,
32+
close_fds: bool = ...,
33+
shell: bool = ...,
34+
cwd: str = ...,
35+
env: Mapping[str, str] = ...,
36+
universal_newlines: bool = ...,
37+
startupinfo: Any = ...,
38+
creationflags: int = ...,
39+
restore_signals: bool = ...,
40+
start_new_session: bool = ...,
41+
pass_fds: Any = ...,
42+
encoding: str = ...,
43+
errors: str = ...) -> CompletedProcess: ...
44+
else:
45+
# Nearly same args as Popen.__init__ except for timeout, input, and check
46+
def run(args: Union[str, Sequence[str]],
47+
timeout: float = ...,
48+
input: Union[str, bytes] = ...,
49+
check: bool = ...,
50+
bufsize: int = ...,
51+
executable: str = ...,
52+
stdin: Any = ...,
53+
stdout: Any = ...,
54+
stderr: Any = ...,
55+
preexec_fn: Callable[[], Any] = ...,
56+
close_fds: bool = ...,
57+
shell: bool = ...,
58+
cwd: str = ...,
59+
env: Mapping[str, str] = ...,
60+
universal_newlines: bool = ...,
61+
startupinfo: Any = ...,
62+
creationflags: int = ...,
63+
restore_signals: bool = ...,
64+
start_new_session: bool = ...,
65+
pass_fds: Any = ...) -> CompletedProcess: ...
4266

4367
# Same args as Popen.__init__
4468
if sys.version_info >= (3, 3):
@@ -207,24 +231,46 @@ class Popen:
207231
pid = 0
208232
returncode = 0
209233

210-
def __init__(self,
211-
args: Union[str, Sequence[str]],
212-
bufsize: int = ...,
213-
executable: Optional[str] = ...,
214-
stdin: Optional[Any] = ...,
215-
stdout: Optional[Any] = ...,
216-
stderr: Optional[Any] = ...,
217-
preexec_fn: Optional[Callable[[], Any]] = ...,
218-
close_fds: bool = ...,
219-
shell: bool = ...,
220-
cwd: Optional[str] = ...,
221-
env: Optional[Mapping[str, str]] = ...,
222-
universal_newlines: bool = ...,
223-
startupinfo: Optional[Any] = ...,
224-
creationflags: int = ...,
225-
restore_signals: bool = ...,
226-
start_new_session: bool = ...,
227-
pass_fds: Any = ...) -> None: ...
234+
if sys.version_info >= (3, 6):
235+
def __init__(self,
236+
args: Union[str, Sequence[str]],
237+
bufsize: int = ...,
238+
executable: Optional[str] = ...,
239+
stdin: Optional[Any] = ...,
240+
stdout: Optional[Any] = ...,
241+
stderr: Optional[Any] = ...,
242+
preexec_fn: Optional[Callable[[], Any]] = ...,
243+
close_fds: bool = ...,
244+
shell: bool = ...,
245+
cwd: Optional[str] = ...,
246+
env: Optional[Mapping[str, str]] = ...,
247+
universal_newlines: bool = ...,
248+
startupinfo: Optional[Any] = ...,
249+
creationflags: int = ...,
250+
restore_signals: bool = ...,
251+
start_new_session: bool = ...,
252+
pass_fds: Any = ...,
253+
encoding: str = ...,
254+
errors: str = ...) -> None: ...
255+
else:
256+
def __init__(self,
257+
args: Union[str, Sequence[str]],
258+
bufsize: int = ...,
259+
executable: Optional[str] = ...,
260+
stdin: Optional[Any] = ...,
261+
stdout: Optional[Any] = ...,
262+
stderr: Optional[Any] = ...,
263+
preexec_fn: Optional[Callable[[], Any]] = ...,
264+
close_fds: bool = ...,
265+
shell: bool = ...,
266+
cwd: Optional[str] = ...,
267+
env: Optional[Mapping[str, str]] = ...,
268+
universal_newlines: bool = ...,
269+
startupinfo: Optional[Any] = ...,
270+
creationflags: int = ...,
271+
restore_signals: bool = ...,
272+
start_new_session: bool = ...,
273+
pass_fds: Any = ...) -> None: ...
228274

229275
def poll(self) -> int: ...
230276
if sys.version_info >= (3, 3):

third_party/3.6/click/core.pyi

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,32 @@ def iter_params_for_processing(
4343

4444

4545
class Context:
46-
parent: Optional['Context']
47-
command: 'Command'
48-
info_name: Optional[str]
49-
params: Dict
50-
args: List[str]
51-
protected_args: List[str]
52-
obj: Any
53-
default_map: Mapping[str, Any]
54-
invoked_subcommand: Optional[str]
55-
terminal_width: Optional[int]
56-
max_content_width: Optional[int]
57-
allow_extra_args: bool
58-
allow_interspersed_args: bool
59-
ignore_unknown_options: bool
60-
help_option_names: List[str]
61-
token_normalize_func: Optional[Callable[[str], str]]
62-
resilient_parsing: bool
63-
auto_envvar_prefix: Optional[str]
64-
color: Optional[bool]
65-
_meta: Dict[str, Any]
66-
_close_callbacks: List
67-
_depth: int
46+
parent = ... # type: Optional['Context']
47+
command = ... # type: 'Command'
48+
info_name = ... # type: Optional[str]
49+
params = ... # type: Dict
50+
args = ... # type: List[str]
51+
protected_args = ... # type: List[str]
52+
obj = ... # type: Any
53+
default_map = ... # type: Mapping[str, Any]
54+
invoked_subcommand = ... # type: Optional[str]
55+
terminal_width = ... # type: Optional[int]
56+
max_content_width = ... # type: Optional[int]
57+
allow_extra_args = ... # type: bool
58+
allow_interspersed_args = ... # type: bool
59+
ignore_unknown_options = ... # type: bool
60+
help_option_names = ... # type: List[str]
61+
token_normalize_func = ... # type: Optional[Callable[[str], str]]
62+
resilient_parsing = ... # type: bool
63+
auto_envvar_prefix = ... # type: Optional[str]
64+
color = ... # type: Optional[bool]
65+
_meta = ... # type: Dict[str, Any]
66+
_close_callbacks = ... # type: List
67+
_depth = ... # type: int
6868

6969
# properties
70-
meta: Dict[str, Any]
71-
command_path: str
70+
meta = ... # type: Dict[str, Any]
71+
command_path = ... # type: str
7272

7373
def __init__(
7474
self,
@@ -141,11 +141,11 @@ class Context:
141141
...
142142

143143
class BaseCommand:
144-
allow_extra_args: bool
145-
allow_interspersed_args: bool
146-
ignore_unknown_options: bool
147-
name: str
148-
context_settings: Dict
144+
allow_extra_args = ... # type: bool
145+
allow_interspersed_args = ... # type: bool
146+
ignore_unknown_options = ... # type: bool
147+
name = ... # type: str
148+
context_settings = ... # type: Dict
149149

150150
def __init__(self, name: str, context_settings: Dict = None) -> None:
151151
...
@@ -182,13 +182,13 @@ class BaseCommand:
182182

183183

184184
class Command(BaseCommand):
185-
callback: Optional[Callable]
186-
params: List['Parameter']
187-
help: Optional[str]
188-
epilog: Optional[str]
189-
short_help: Optional[str]
190-
options_metavar: str
191-
add_help_option: bool
185+
callback = ... # type: Optional[Callable]
186+
params = ... # type: List['Parameter']
187+
help = ... # type: Optional[str]
188+
epilog = ... # type: Optional[str]
189+
short_help = ... # type: Optional[str]
190+
options_metavar = ... # type: str
191+
add_help_option = ... # type: bool
192192

193193
def __init__(
194194
self,
@@ -244,11 +244,11 @@ _Decorator = Callable[[_T], _T]
244244

245245

246246
class MultiCommand(Command):
247-
no_args_is_help: bool
248-
invoke_without_command: bool
249-
subcommand_metavar: str
250-
chain: bool
251-
result_callback: Callable
247+
no_args_is_help = ... # type: bool
248+
invoke_without_command = ... # type: bool
249+
subcommand_metavar = ... # type: str
250+
chain = ... # type: bool
251+
result_callback = ... # type: Callable
252252

253253
def __init__(
254254
self,
@@ -283,7 +283,7 @@ class MultiCommand(Command):
283283

284284

285285
class Group(MultiCommand):
286-
commands: Dict[str, Command]
286+
commands = ... # type: Dict[str, Command]
287287

288288
def __init__(
289289
self, name: str = None, commands: Dict[str, Command] = None, **attrs
@@ -301,7 +301,7 @@ class Group(MultiCommand):
301301

302302

303303
class CommandCollection(MultiCommand):
304-
sources: List[MultiCommand]
304+
sources = ... # type: List[MultiCommand]
305305

306306
def __init__(
307307
self, name: str = None, sources: List[MultiCommand] = None, **attrs
@@ -313,22 +313,22 @@ class CommandCollection(MultiCommand):
313313

314314

315315
class Parameter:
316-
param_type_name: str
317-
name: str
318-
opts: List[str]
319-
secondary_opts: List[str]
320-
type: 'ParamType'
321-
required: bool
322-
callback: Optional[Callable[[Context, 'Parameter', str], Any]]
323-
nargs: int
324-
multiple: bool
325-
expose_value: bool
326-
default: Any
327-
is_eager: bool
328-
metavar: Optional[str]
329-
envvar: Union[str, List[str], None]
316+
param_type_name = ... # type: str
317+
name = ... # type: str
318+
opts = ... # type: List[str]
319+
secondary_opts = ... # type: List[str]
320+
type = ... # type: 'ParamType'
321+
required = ... # type: bool
322+
callback = ... # type: Optional[Callable[[Context, 'Parameter', str], Any]]
323+
nargs = ... # type: int
324+
multiple = ... # type: bool
325+
expose_value = ... # type: bool
326+
default = ... # type: Any
327+
is_eager = ... # type: bool
328+
metavar = ... # type: Optional[str]
329+
envvar = ... # type: Union[str, List[str], None]
330330
# properties
331-
human_readable_name: str
331+
human_readable_name = ... # type: str
332332

333333
def __init__(
334334
self,
@@ -388,17 +388,17 @@ class Parameter:
388388

389389

390390
class Option(Parameter):
391-
prompt: str # sic
392-
confirmation_prompt: bool
393-
hide_input: bool
394-
is_flag: bool
395-
flag_value: Any
396-
is_bool_flag: bool
397-
count: bool
398-
multiple: bool
399-
allow_from_autoenv: bool
400-
help: Optional[str]
401-
show_default: bool
391+
prompt = ... # type: str # sic
392+
confirmation_prompt = ... # type: bool
393+
hide_input = ... # type: bool
394+
is_flag = ... # type: bool
395+
flag_value = ... # type: Any
396+
is_bool_flag = ... # type: bool
397+
count = ... # type: bool
398+
multiple = ... # type: bool
399+
allow_from_autoenv = ... # type: bool
400+
help = ... # type: Optional[str]
401+
show_default = ... # type: bool
402402

403403
def __init__(
404404
self,

0 commit comments

Comments
 (0)