Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argparse Incorrect Handling of Store Actions #72744

Closed
FluxIX mannequin opened this issue Oct 29, 2016 · 2 comments
Closed

argparse Incorrect Handling of Store Actions #72744

FluxIX mannequin opened this issue Oct 29, 2016 · 2 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@FluxIX
Copy link
Mannequin

FluxIX mannequin commented Oct 29, 2016

BPO 28558
Nosy @zhangyangyu, @FluxIX
Files
  • test_argparse.py: Example of Error
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-10-29.17:29:05.017>
    created_at = <Date 2016-10-29.17:21:51.059>
    labels = ['type-bug', 'invalid']
    title = 'argparse Incorrect Handling of Store Actions'
    updated_at = <Date 2016-10-29.17:29:24.421>
    user = 'https://github.com/FluxIX'

    bugs.python.org fields:

    activity = <Date 2016-10-29.17:29:24.421>
    actor = 'xiang.zhang'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-10-29.17:29:05.017>
    closer = 'xiang.zhang'
    components = []
    creation = <Date 2016-10-29.17:21:51.059>
    creator = 'Flux'
    dependencies = []
    files = ['45266']
    hgrepos = []
    issue_num = 28558
    keywords = []
    message_count = 2.0
    messages = ['279686', '279687']
    nosy_count = 2.0
    nosy_names = ['xiang.zhang', 'Flux']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue28558'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @FluxIX
    Copy link
    Mannequin Author

    FluxIX mannequin commented Oct 29, 2016

    argparse does not handle Store actions correctly when "nargs = 1" is provided. The documentation indicates the value should be assigned to the dest, but instead a list with the value as the only item is assigned to dest.

    @FluxIX FluxIX mannequin added the type-bug An unexpected behavior, bug, or error label Oct 29, 2016
    @zhangyangyu
    Copy link
    Member

    This is the expected behaviour. The doc explicitly says "Note that nargs=1 produces a list of one item. This is different from the default, in which the item is produced by itself". Read https://docs.python.org/3/library/argparse.html#nargs.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant