[issue25308] Multiple names can target the same namespace

2015-10-06 Thread paul j3
paul j3 added the comment: What you are asking about is the fact that different arguments can share a 'dest'. https://docs.python.org/3/library/argparse.html#dest The 'append_const' action has an example of shared 'dest'. It says: The 'append_con

[issue18769] argparse remove subparser

2015-10-11 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue18769> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue18769] argparse remove subparser

2015-10-11 Thread paul j3
paul j3 added the comment: Under what circumstances would this be useful? http://bugs.python.org/issue19462 asks for a 'remove_argument' method. That seems to be most useful if the argument is inherited from a parent parser. A subparsers argument could be inherited from a paren

[issue18769] argparse remove subparser

2015-10-12 Thread paul j3
paul j3 added the comment: There's a partial overlap with this issue http://bugs.python.org/issue22848 which seeks to hide a subparser - both in the help lines and the choices lists. -- ___ Python tracker <http://bugs.python.org/is

[issue25436] argparse.ArgumentError missing error message in __repr__

2015-10-19 Thread paul j3
paul j3 added the comment: The short `repr` is produced in Python2.7, but not 3.5. Your test case: action = argparse._StoreAction(['--file], dest='file_path') error = argparse.ArgumentError(action, 'File not found.') print(str(error)) print(repr(err

[issue11174] add argparse formatting option to display type names for metavar

2015-10-19 Thread paul j3
paul j3 added the comment: This formatter produces an error if one or more of the arguments uses the default `None` type (a string). This is because `None` does not have a `.__name__`. This HelpFormatter probably has been rarely, if ever, used. The metavar parameter works just as well

[issue25061] Add native enum support for argparse

2015-11-04 Thread paul j3
paul j3 added the comment: The choice of 'type' for this parameter is occasionally confusing, because the connection to the Python 'type()' function or what we think of as 'native types' is only tangential. A name like 'converter' or 'string_co

[issue25882] argparse help error: arguments created by add_mutually_exclusive_group() are shown outside their parent group created by add_argument_group()

2015-12-16 Thread paul j3
paul j3 added the comment: In _ActionsContainer._add_container_actions there is this note: # add container's mutually exclusive groups # NOTE: if add_mutually_exclusive_group ever gains title= and # description= then this code will need to be expanded as above In other bug/i

[issue25882] argparse help error: arguments created by add_mutually_exclusive_group() are shown outside their parent group created by add_argument_group()

2015-12-16 Thread paul j3
paul j3 added the comment: I've attached a file that monkey patches the _ActionsContainer._add_container_actions method. It corrects the `_container` attribute of the copied mutually exclusive groups. I've only tested it for the case presented in this issue (and the relate Sta

[issue25882] argparse help error: arguments created by add_mutually_exclusive_group() are shown outside their parent group created by add_argument_group()

2015-12-17 Thread paul j3
paul j3 added the comment: Argument groups are not designed to be nested. If you print_help the parent parser, you'll see that the sub_args are missing entirely, not just displaced. They appear in the usage, but not the help lines. sub_group has no record that it was added to global_

[issue26181] argparse can't handle positional argument after list (help message is wrong)

2016-01-27 Thread paul j3
paul j3 added the comment: There are 2 issues parsing - how to reserve one or more arguments for use by following 'positionals'. Fixes have been proposed in other bug/issues, but aren't trivial. usage formatting - the stock formatter displays all optionals first, f

[issue20598] argparse docs: '7'.split() is confusing magic

2016-01-28 Thread paul j3
paul j3 added the comment: I can understand changing '7'.split() but this change is IMO ugly: - >>> print(parser.parse_args('--foo B cmd --arg1 XX ZZ'.split())) + >>> print(parser.parse_args(['--foo', 'B', 'cmd'

[issue25314] Documentation: argparse's actions store_{true, false} default to False/True (undocumented)

2016-01-28 Thread paul j3
paul j3 added the comment: How about: These store the values True and False respectively (and default to False and True if absent). The reference to `store_const` is confusing, since almost no one uses that action. The `store_const` paragraph has: (Note that the const keyword

[issue26235] argparse docs: Positional * argument in mutually exclusive group requires a default parameter

2016-01-28 Thread paul j3
New submission from paul j3: The documentation for Mutual exclusion https://docs.python.org/3/library/argparse.html#mutual-exclusion needs a note that a mutually exclusive group may contain one positional argument. But that argument must be either nargs='?', or nargs='*

[issue26510] [argparse] Add required argument to add_subparsers

2016-03-10 Thread paul j3
paul j3 added the comment: This has been raised before. I think http://bugs.python.org/issue9253 is the correct issue. It used to be that 'subparsers' were required. But there was a change in how 'required' arguments were tested, and 'subparsers' fell throug

[issue26503] argparse with required field , not having new line separator in -help dispaly

2016-03-10 Thread paul j3
paul j3 added the comment: The usage line formatter needs a major rewrite. Currently it formats usage for all the arguments as one line (two actually, optionals and positionals are handled separately), and then breaks it into 'wrappable parts'. It then compiles the lines from t

[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-10 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue26394> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-10 Thread paul j3
paul j3 added the comment: I need to study that patch more, but I don't like the fact that it operates at the core of the parsing (e.g. in 'take_action'). That's a dangerous place to add features. Unexpected behaviors and backwards compatibility problems are too likely.

[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-10 Thread paul j3
paul j3 added the comment: Let's see if I understand the proposed patch Each call to 'take_action' is replaced with a save to a 'action_with_values' dictionary For a flagged (optional) it saves the 'args' and 'option_string'; for positionals

[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-10 Thread paul j3
paul j3 added the comment: http://stackoverflow.com/a/35144270/901925 dynamically-set-default-value-from-cfg-file-through-argparse-python is my answer to a similar recent (Feb 2015) SO question. I rather like the idea of using collections.ChainMap on the dictionary versions of the namespace

[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-11 Thread paul j3
paul j3 added the comment: Yes, the use of ordered dictionary would be right. Your code would still reorder actions that have fallback values, but that wouldn't affect others. Yes, a fallback hook at the end of parsing would have to be placed before the 'required' testing, not

[issue9694] argparse required arguments displayed under "optional arguments"

2016-03-23 Thread paul j3
paul j3 added the comment: This ArgumentDefaultHelpFormatter issue should probably be raised in its own issue. It applies to 'required' optionals, but any patch would be independent of the issues discussed here. This class defines a method that adds the '%(default)' s

[issue26602] argparse doc introduction is inappropriately targeted

2016-03-23 Thread paul j3
paul j3 added the comment: By text and location the sidebar does not apply specifically to this example. It applies to the whole page, 'This page contains the API reference information.' Documentation for argparse is indeed a problem - both because of its complexity and how

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2016-03-23 Thread paul j3
paul j3 added the comment: Is this the kind of scenario that you have problems with? parser = argparse.ArgumentParser() sp = parser.add_subparsers(dest='cmd') p1 = sp.add_parser('cmd1') p1.add_argument('-f') p2 = sp.add_parser('cmd2&

[issue9694] argparse required arguments displayed under "optional arguments"

2016-03-23 Thread paul j3
paul j3 added the comment: I can see changing the group title from 'optional arguments' to 'options' or 'optionals' parser._optionals.title 'optional arguments' But I don't think there's a need to change references in the code or it

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2016-03-24 Thread paul j3
paul j3 added the comment: Neither 'parents' or 'resolve' are documented in any detail. Most of what I know comes from reading the code. 'parents' are, I think, most useful when importing a parser from some other module. It lets you add arguments to your own p

[issue14364] Argparse incorrectly handles '--' as argument to option

2016-03-27 Thread paul j3
paul j3 added the comment: I made a mistake of trying to add to or refine a closed patch. Maybe I need to move the dbldash.patch over here for more formal consideration. -- ___ Python tracker <http://bugs.python.org/issue14

[issue25061] Add native enum support for argparse

2016-04-11 Thread paul j3
paul j3 added the comment: The best way to get an idea added is to write a good complete patch. 2nd best is to provide constructive input on ideas that are already here. 3rd is to illustrate how you would hope to use such a feature. Include ideas on how the usage/help/error display would

[issue25061] Add native enum support for argparse

2016-04-11 Thread paul j3
paul j3 added the comment: desbma: Rereading your latest code and comment: > * The meaning of the 'type' parameter for StoreEnumAction is somewhat > different than for other actions (enum class vs callable that validates) it occurred to me that that parameter does not have t

[issue20430] Make argparse.SUPPRESS work as an argument "dest"

2016-04-24 Thread paul j3
paul j3 added the comment: I just found a case where `dest` is `SUPPRESS` - the default subparsers setup. _SubParsersAction(option_strings=[], dest='==SUPPRESS==', nargs='A...', ... If I make this Action 'required' (in the current distribution 'subpar

[issue26967] argparse: allow_abbrev=False stops -vv from working

2016-05-08 Thread paul j3
Changes by paul j3 : -- priority: normal -> high ___ Python tracker <http://bugs.python.org/issue26967> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue26967] argparse: allow_abbrev=False stops -vv from working

2016-05-08 Thread paul j3
paul j3 added the comment: It's been 2 years since I worked on this patch. In the issue discussion http://bugs.python.org/issue14910 there was no mention of short v long options. The unit tests only look at longs. The result is that with the abbrev off, it disables all use of com

[issue26952] argparse help formatter crashes

2016-05-08 Thread paul j3
paul j3 added the comment: Argument Groups are not designed for nesting, and despite their names and subclassing, Mutually exclusive groups and Argument Groups are not meant to be used together (with one exception). I agree that the error is obscure, but it occurs in a particularly fragile

[issue26967] argparse: allow_abbrev=False stops -vv from working

2016-05-08 Thread paul j3
paul j3 added the comment: Someone needs to take the current argparse.py, set the default value of this parameter to False, and run the unittest file. This should turn up this case, and possibly others that fail when abbreviations are turned off. Then we have to debate whether such failures

[issue26994] unexpected behavior for booleans in argparse

2016-05-14 Thread paul j3
paul j3 added the comment: I answered a similar question recently on Stackoverflow when the user wanted to use `type=hex`. http://stackoverflow.com/questions/37006387/python-argparse-hex-error In another recent bug/issue the poster want a `enum` type. It's not hard to define a functio

[issue11588] Add "necessarily inclusive" groups to argparse

2016-05-16 Thread paul j3
paul j3 added the comment: So far I've proposed adding a 'hook' at the end of '_parse_known_args', that would give the user access to the 'seen_non_default_actions' variable. This function could perform an almost arbitrarily complex set of logical co-occurr

[issue23159] argparse: Provide equivalent of optparse.OptionParser.{option_groups, option_list, get_option}

2015-03-21 Thread paul j3
paul j3 added the comment: The attached file subclasses ArgumentParser, explores how these optparse methods might be added to argparse. The __name__ section demonstrates how they might be used. argparse differs from optparse in a number of ways: - all actions are included in the parser

[issue23487] argparse: add_subparsers 'action' broken

2015-03-22 Thread paul j3
paul j3 added the comment: It certainly looks like a documentation issue. `action` doesn't make sense here. `add_subparsers` normally creates an Action of type `_SubParsersAction`. 'action' for normal 'add_argument' command defines the Action type created at

[issue23378] argparse.add_argument action parameter should allow value extend

2015-03-22 Thread paul j3
paul j3 added the comment: My opinion is that this is an unnecessary addition. Reasons: - it is easy to add as a custom action class - I haven't seen other requests for it - the append retains information about the argument strings that extend looses - it is easy flatten the app

[issue23298] Add ArgumentParser.add_mutually_dependence_group

2015-03-22 Thread paul j3
paul j3 added the comment: http://bugs.python.org/issue11588 is an earlier request for 'necessarily inclusive' groups. The patches that I proposed there are more general, allowing for other logical combinations of arguments, as well as nesting groups. As such it is more complex

[issue23487] argparse: add_subparsers 'action' broken

2015-03-25 Thread paul j3
paul j3 added the comment: OK, so you are thinking about what happens to the subparsers `dest` when the user names a command. That isn't handled by the `store` action, but by the call of the subparsers action class _SubParsersAction(Action): def __c

[issue23487] argparse: add_subparsers 'action' broken

2015-03-25 Thread paul j3
Changes by paul j3 : -- assignee: -> docs@python components: +Documentation nosy: +docs@python ___ Python tracker <http://bugs.python.org/issue23487> ___ _

[issue23487] argparse: add_subparsers 'action' broken

2015-03-25 Thread paul j3
paul j3 added the comment: As to the nature of the error when 'add_subparsers' is given an 'action' parameter: 'add_subparsers' does several things to 'kwargs' before it passes them to the relevant Action class. def add_subparsers(self,

[issue23795] argparse -- incorrect usage for mutually exclusive

2015-03-27 Thread paul j3
paul j3 added the comment: I can't reproduce this with either 3.4.2 or the latest development 'argparse.py' file (that I just downloaded). There have been some issues with the method used format the usage line, _format_actions_usage. It formats the line with all the group brac

[issue23058] argparse silently ignores arguments

2015-03-27 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue23058> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue23058] argparse silently ignores arguments

2015-03-27 Thread paul j3
paul j3 added the comment: Without actually running this case I think it is caused by the http://bugs.python.org/issue9351 patch. You can check the __call__ method for class _SubParsersAction and how it handles invocation of the subparser. Does it get the existing namespace, or a new one

[issue23555] behavioural change in argparse set_defaults in python 2.7.9

2015-03-27 Thread paul j3
paul j3 added the comment: This is another manifestation of the http://bugs.python.org/issue9351 partial patch (on how the namespace of the parser relates to the namespace of the subparser). see also http://bugs.python.org/issue23058 -- ___ Python

[issue23555] behavioural change in argparse set_defaults in python 2.7.9

2015-03-27 Thread paul j3
Changes by paul j3 : -- status: open -> closed ___ Python tracker <http://bugs.python.org/issue23555> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2015-03-27 Thread paul j3
paul j3 added the comment: http://bugs.python.org/issue22672 float arguments in scientific notation not supported by argparse is a newer complaint about the same issue. I've closed it with link to here. -- ___ Python tracker

[issue22672] float arguments in scientific notation not supported by argparse

2015-03-27 Thread paul j3
paul j3 added the comment: closed with reference to #9334 -- status: open -> closed ___ Python tracker <http://bugs.python.org/issue22672> ___ ___ Python-

[issue22500] Argparse always stores True for positional arguments

2015-03-27 Thread paul j3
Changes by paul j3 : -- status: open -> closed ___ Python tracker <http://bugs.python.org/issue22500> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue23814] argparse: Parser level defaults do not always override argument level defaults

2015-03-31 Thread paul j3
paul j3 added the comment: The handling of defaults is a bit complicated. Note that `set_defaults` both sets a `_defaults` attribute, and any actions with a matching `dest`. So it could change the `default` of 0, 1 or more actions. def set_defaults(self, **kwargs): self

[issue23884] New DateType for argparse (like FileType but for dates)

2015-04-07 Thread paul j3
paul j3 added the comment: It's a possible addition, but I don't have sense of the demand for it. I wonder, what does the class offer that a function like this doesn't? def adate(date_string): return datetime.datetime.strptime(date_string,'%Y-%m-%d').date(

[issue23884] New DateType for argparse (like FileType but for dates)

2015-04-07 Thread paul j3
paul j3 added the comment: Examples of datetime types from Stackoverflow: http://stackoverflow.com/questions/21437258/defining-python-argparse-arguments The suggested answer (but not accepted) is 'type=lambda s: datetime.datetime.strptime(s, '%Y-%m-%d')' another http

[issue22848] Subparser help does not respect SUPPRESS argument

2015-04-15 Thread paul j3
paul j3 added the comment: It'll take me a while to work through this proposed patch. My first reaction is that I am uncomfortable with adding an attribute to all parsers just to implement this help feature. For one thing it seems to cross functionality boundaries. I need to revie

[issue22848] Subparser help does not respect SUPPRESS argument

2015-04-16 Thread paul j3
paul j3 added the comment: Giving the `subparsers` Action a `metavar` might achieve everything the proposed patch does - without any code changes. In the 1st test case: subparsers = parser.add_subparsers(title='subcommands', d

[issue23994] argparse fails to detect program name when there is a slash at the end of the program's path

2015-04-21 Thread paul j3
paul j3 added the comment: This overlaps with http://bugs.python.org/issue22240 argparse support for "python -m module" in help This issue also tries to handle zip files as well. Deducing the `prog` was moved to a separate function. One challenge with that issue was construct

[issue22848] Subparser help does not respect SUPPRESS argument

2015-04-22 Thread paul j3
paul j3 added the comment: A similar Stackoverflow question http://stackoverflow.com/questions/21692395/hiding-selected-subcommands-using-argparse/21712058#21712058 -- ___ Python tracker <http://bugs.python.org/issue22

[issue24089] argparse crashes with AssertionError

2015-05-02 Thread paul j3
paul j3 added the comment: It's the spaces and/or brackets in the metavar, along with a usage line that is long enough to wrap, that is raising this error. It's a known problem. http://bugs.python.org/issue11874 -- nosy: +paul.j3

[issue24166] ArgumentParser behavior does not match generated help

2015-05-11 Thread paul j3
paul j3 added the comment: I wouldn't describe this as bug, just a nuance on how parsers and subparsers play together. To the main parser, the subparser argument looks like another positional. It allocates strings to it and any following positionals based on their respective 'na

[issue24166] ArgumentParser behavior does not match generated help

2015-05-11 Thread paul j3
paul j3 added the comment: And the behavior does match the help {ls,du} ... vm [vm ...] It's just that one of the strings is allocated to the first `...`, whereas you expected it to be put in the second. -- ___ Python tracker

[issue24166] ArgumentParser behavior does not match generated help

2015-05-12 Thread paul j3
paul j3 added the comment: Look at http://bugs.python.org/issue9338 argparse optionals with nargs='?', '*' or '+' can't be followed by positionals That has a proposed patch that wraps the main argument consumption loop in another loop. The current loop a

[issue27927] argparse: default propagation of formatter_class from ArgumentParser() to SubParsers

2016-09-03 Thread paul j3
paul j3 added the comment: http://bugs.python.org/issue21633 also deals with the formatter of subparsers. I note there that few of parameters of the main parser propagate to the subparsers. The current design gives the programmer maximum control, at the expense of a bit of typing. If I

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2016-09-03 Thread paul j3
paul j3 added the comment: Another example where the old way would have worked better http://bugs.python.org/issue27859 -- ___ Python tracker <http://bugs.python.org/issue9

[issue27859] argparse - subparsers does not retain namespace

2016-09-03 Thread paul j3
paul j3 added the comment: This call used to be namespace, arg_strings = parser.parse_known_args(arg_strings, namespace) But in 2014 (2.7.9) http://bugs.python.org/issue9351 was implemented As noted in the title and comment in the code, the idea was to give more power to the defaults set

[issue27859] argparse - subparsers does not retain namespace

2016-09-04 Thread paul j3
paul j3 added the comment: I've posted a file that runs your code as you expect. It uses a custom Action class (like your test case). It subclasses ._SubParsersAction, and replaces the 9351 namespace use with the original one. I use the registry to change the class

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2016-09-04 Thread paul j3
paul j3 added the comment: In http://bugs.python.org/issue27859 I've demonstrated how a subclass of _SubParsersAction can be used to revert the behavior to pre 2.7.9, passing the main namespace to the subparser. The only other change is to the parser registry: parser.register(&#

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2016-09-04 Thread paul j3
Changes by paul j3 : -- Removed message: http://bugs.python.org/msg274336 ___ Python tracker <http://bugs.python.org/issue9351> ___ ___ Python-bugs-list mailin

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2016-09-14 Thread paul j3
paul j3 added the comment: Clint, 'nargs=argparser.REMAINDER' ('...') may do what you want p=argparse.ArgumentParser() p.add_argument('--subscipt_args', nargs='...') p.add_argument('pos',nargs='*') p.parse_

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2016-09-15 Thread paul j3
paul j3 added the comment: Clint, the problem is the argparse uses different argument allocation method than optparse. optparse gives the '--subscipt_args` Action all of the remaining strings, and says - 'consume what you want, and return the rest'. So you consume up to (and

[issue28219] Is order of argparse --help output officially defined?

2016-09-27 Thread paul j3
paul j3 added the comment: The display of the Action help lines is determined by the parser.format_help function https://docs.python.org/3/library/argparse.html#printing-help This function creates a Formatter, and then loads it with a 'stack' of sections. Sections are display

[issue28210] argparse with subcommands difference in python 2.7 / 3.5

2016-09-27 Thread paul j3
paul j3 added the comment: Yes there was/is a bug that made subparsers optional. http://bugs.python.org/issue9253 -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue28

[issue16399] argparse: append action with default list adds to list instead of overriding

2016-10-02 Thread paul j3
paul j3 added the comment: It may help to know something about how defaults are handled - in general. `add_argument` and `set_defaults` set the `default` attribute of the Action (the object created by `add_argument` to hold all of its information). The default `default` is `None`. At the

[issue16399] argparse: append action with default list adds to list instead of overriding

2016-10-02 Thread paul j3
paul j3 added the comment: One thing that this default behavior does is allow us to append values to any object, just so long as it has the `append` method. The default does not have to be a standard list. For example, in another bug/issue someone asked for an `extend` action. I could

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3
paul j3 added the comment: The current error message is the result of http://bugs.python.org/issue10424 and http://bugs.python.org/issue12776 Before the test was just: if positionals: self.error(_('too few arguments')) The 2nd patch reworked the test to include the revise

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3
paul j3 added the comment: Try `nargs='?'` or try providing a `default` along with the '*'. Including your ARGUMENT action in the error message is intentional. The test for this error message is: required_actions = [] for action in self._actions:

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3
paul j3 added the comment: Simply including a `default` parameter, even with the default default None, changes the error message In [395]: parser=argparse.ArgumentParser() In [396]: parser.add_argument('cmd'); In [397]: a=parser.add_argument('args',na

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3
paul j3 added the comment: My suggestion to use `metavar=('A','')` to streamline the usage creates problems with the help code http://bugs.python.org/issue14074 The tuple metavar does not work right for positionals. That's a old issue that should have been fixed l

<    3   4   5   6   7   8