Jelle Zijlstra
5d553c9584
apply black and isort ( #4287 )
...
* apply black and isort
* move some type ignores
2020-06-28 13:31:00 -07:00
Shantanu
9a16b02187
argparse: fix for latest py39 ( #4267 )
...
https://github.com/python/typeshed/pull/4144 and
https://github.com/python/cpython/pull/11478#pullrequestreview-423968410
resulted in the issue being fixed upstream.
Co-authored-by: hauntsaninja <>
2020-06-26 12:55:23 +02:00
Shantanu
5369e813a9
argparse: fix error __init__, add BooleanOptionalAction for py39 ( #4144 )
2020-06-04 16:00:52 -07:00
Shantanu
02e1a68a56
argparse: add Action.format_usage ( #4114 )
...
Co-authored-by: hauntsaninja <>
2020-05-27 18:36:01 -07:00
Shantanu
3910eb1735
argparse: update for py39 ( #4065 )
...
Co-authored-by: hauntsaninja <>
2020-05-24 17:40:06 -07:00
Shantanu
98c6bf8272
argparse: allow passing a callable to ArgumentParser ( #3821 )
...
Fixes #3806
2020-03-06 11:24:50 +01:00
Shantanu
123d2cb093
argparse: fix RawTextHelpFormatter base class ( #3703 )
2020-02-01 09:14:29 -08:00
Shantanu
d889de033a
argparse: various fixes ( #3630 )
...
- add_subparsers uses keyword-only args
- required parameter is new in py37
2020-01-21 19:38:58 +01:00
jjmortensen
686e21d330
Fix type in argparse.HelpFormatter._fill_text() ( #3229 )
2019-09-11 17:00:25 +02:00
Rebecca Chen
fab2ee0d7c
Remove unnecessary quotes around forward references. ( #3191 )
2019-08-16 20:29:32 -07:00
Utkarsh Gupta
020449a1ed
argparse.pyi: Allow Callable[[Text], _T] ( #3013 )
...
Fixes #2988
2019-05-27 14:39:04 +02:00
Sebastian Rittau
260369e6e7
Use typing.Text for argument types ( #3000 )
...
Also, use just str for argument types in Python 3+ branches.
2019-05-21 19:53:47 -07:00
cormoran
632eadc894
Make metavar in argparse be Optional ( #2739 )
2019-01-13 12:09:06 +01:00
Daniel Mouritzen
fb8b77e715
Set correct type for _subparsersaction.choices ( #2702 )
...
choices=_name_parser_map, see a11d44056e/Lib/argparse.py (L1097)
2018-12-20 19:44:30 -08:00
Guido van Rossum
f9ba5402f8
Improve overloads of parse_args() -- it never returns None ( #2643 )
...
Fixes #2641
2018-11-27 18:11:30 -08:00
PRAJWAL M
60000d0898
correct parse_args namespace attribute ( #2566 )
...
Closes #2366
2018-10-28 18:48:34 +01:00
Christian Haudum
daae0c7980
Allow any keyword argument in argparse add_argument() method ( #2460 )
...
Closes #2457
2018-09-15 22:05:15 +02:00
Anthony Sottile
c3cf369c6f
Document required= argument for add_subparsers in py37+ ( #2416 )
2018-08-23 19:39:34 -07:00
Jelle Zijlstra
5554b0b19b
argparse.ArgumentParser.error never returns ( #2082 )
...
And neither does `.exit`.
Fixes #2081 .
2018-04-25 21:30:31 -07:00
Michael J. Sullivan
d63866bd36
Fix py2 unicode handling for ArgumentParser.add_argument's text arg ( #2051 )
...
add_argument's type argument was recently changed to be (approximately)
`Callable[[_Text], _T]`. Because of contravariant subtyping for functions,
this had the effect of requiring that add_argument *always*
be unicode, which is wrong.
Change it to be `Callable[[str], _T]`.
2018-04-12 20:45:48 -07:00
Chris Gavin
dca53fb2bd
Make the help argument of argparse.add_argument Optional. ( #2046 )
2018-04-11 07:20:16 -07:00
Jelle Zijlstra
db989427cb
dest argument to add_argument is Optional ( #2040 )
...
argparse.py checks for None in _get_optional_kwargs.
2018-04-10 21:47:30 -07:00
rchen152
e2cfc4bf0f
Add private members to argparse.pyi. ( #1937 )
...
* Add _AttributeHolder and _ActionsContainer classes to argparse.
* Add Action subclasses to argparse.
* Add _UNRECOGNIZED_ARGS_ATTR, _ensure_value, _get_action_name to argparse.
* Fill in remaining _ActionsContainer attributes.
* Fill in missing argparse.ArgumentParser attributes.
* Fill in missing argparse.HelpFormatter attributes.
* Fill in remaining missing attributes on argparse classes.
* Rename TypeVar _ActionVar to _ActionT
* Add a version check for FileType attributes
* Add '# undocumented' where appropriate
* Add more # undocumented comments
* Make arguments to _ActionsContainer.add_argument more precise.
2018-04-10 20:56:49 -07:00
Evan Krall
4563c5a1ac
ArgumentParser's add_argument returns the Action that was created. ( #1881 )
...
* ArgumentParser's add_argument returns the Action that was created.
* Make add_argument's dest parameter Optional. _ArgumentGroup's add_argument should also return the Action.
2018-03-28 19:09:22 -07:00
rchen152
e1243d0103
Add missing attributes, fix some parameter types in argparse.Action. ( #1907 )
2018-02-28 11:20:04 -08:00
Neil Conway
46125886c0
argparse: Add annotations for instance variables. ( #1763 )
2017-12-12 15:10:31 -08:00
Robert T. McGibbon
f1a13cea9c
Add __init__ and __contains__ to argparse.Namespace ( #1578 )
2017-08-27 14:14:01 -07:00
Jukka Lehtosalo
97bd6e37b9
Update argparse to accept unicode in many contexts
...
Change `str` to `Union[str, unicode]` where it seems safe.
I didn't change it in non-covariant contexts since that can
break user code.
I manually verified a subset of the changes by calling the
relevant function with unicode literals (ascii-only).
I'm using `Union[str, unicode]` instead of just `unicode`
so that the stub still works with tools that don't promote
`str` objects to `unicode`.
2017-01-18 08:43:49 -08:00
Robin Alazard
1002950322
Add missing method add_mutually_exclusive_group(...) to argparse group ( #573 )
2016-09-26 12:07:47 -07:00
Tom Manderson
9fd0fd97c6
Make FileType valid for ArgumentParser 'type' arg ( #473 )
2016-08-15 11:42:48 -07:00
Guido van Rossum
39325bf159
Mypy now supports sys.platform and sys.version_info checks ( #410 )
2016-07-27 13:25:29 -07:00
jdelic
ba69b32d06
argparse stub fix: parse_known_args takes an optional sequence of strings like parse_args(), not an optional string ( #386 )
...
* parse_known_args takes an optional sequence of strings like parse_args, not an optional string
2016-07-22 14:39:56 -07:00
jdelic
791966a65a
argparse stub fix: allow subclasses of Action in add_argument(action=...) ( #385 )
...
The action was incorrectly typed as allowing instances of Action -- the correct type is subclasses of Action. (And str.)
2016-07-22 14:38:24 -07:00
jdelic
05cd6ec5fa
List should probably be Sequence ( #387 )
2016-07-22 13:19:49 -07:00
jdelic
4f7c9ce432
argparse stub fix: values parameter of Action can also be str and None ( #388 )
...
* values can be a str, too
* values should probably use Sequence
2016-07-22 10:58:59 -07:00
alvarocaceres
f7b35bc8be
Remove line continuations to help pytype parse ( #390 )
2016-07-22 10:55:42 -07:00
Guido van Rossum
53d126f4d4
More fixes for argparse. ( #362 )
2016-07-13 07:51:29 -07:00
Guido van Rossum
b63e09c239
Fix some issues for dateutil and argparse ( #357 )
...
* Fix stubs for 2.7/dateutil. They were pretty broken.
(The 3/dateutil share some of the brokenness but that's still a TODO.)
* Fix argparse stubs.
- Container is not strong enough for choices.
- add_subparsers() returns something with an add_parser() method.
2016-07-12 16:24:33 -07:00
tharvik
87235ad72b
merge py2 and py3 argparse
2016-07-11 15:23:51 +02:00