Skip to content

ArgumentContext.ignore should mangle the options list for ignored arguments #74

@tjprescott

Description

@tjprescott

If I have:

with ArgumentContext('foo') as c:
  c.argument('arg1', options_list=['--this'])

with ArgumentContext('foo bar') as c:
   c.ignore('arg1')
   c.argument('arg2', options_list=['--this'])

I will get an error because, although arg1 would be ignored, argparse sees a name conflict between arg1 and arg2. If the ignore method automatically changed the options_list to something else --__ARG1 for instance, then it won't produce the conflict and avoids me having to do this:

with ArgumentContext('foo') as c:
  c.argument('arg1', options_list=['--this'])

with ArgumentContext('foo bar') as c:
   c.argument('arg1', ignore_type, options_list=['--literally-anything-else'])
   c.argument('arg2', options_list=['--this'])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions