GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — argparse.BooleanOptionalAction accepts and silently discards choices, metavar, and type arguments · Issue #92248 · python/cpython

argparse.BooleanOptionalAction accepts and silently discards choices, metavar, and type arguments #92248

New issue
Copy link
New issue
Copy link
Closed
Closed
argparse.BooleanOptionalAction accepts and silently discards choices, metavar, and type arguments#92248
Copy link
Assignees
sobolevn
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@samwyse
samwyse
opened on May 3, 2022
Issue body actions

This is an elaboration of issue #85039.

>>> parser = ArgumentParser()
>>> parser.add_argument('--foo', action=BooleanOptionalAction,
...     choices=[1,2], metavar='FOOBAR', type=int)  # doctest: +ELLIPSIS
BooleanOptionalAction(...)

Note that the store_const, store_true, and store_false actions disallow those keyword arguments.

>>> parser.add_argument('--bar', action='store_true', choices=[1,2])
Traceback (most recent call last):
  ...
TypeError: __init__() got an unexpected keyword argument 'choices'
>>> parser.add_argument('--bar', action='store_true', metavar='FOOBAR')
Traceback (most recent call last):
  ...
TypeError: __init__() got an unexpected keyword argument 'metavar'
>>> parser.add_argument('--bar', action='store_true', type=int)
Traceback (most recent call last):
  ...
TypeError: __init__() got an unexpected keyword argument 'type'
>>> parser.add_argument('--bar', action='store_true')  # doctest: +ELLIPSIS
_StoreTrueAction(...)

Linked PRs

  • gh-92248: Deprecate type, choices, metavar parameters of argparse.BooleanOptionalAction #103678

Activity

  1. samwyse
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 3, 2022
  2. erlend-aasland
    added this to Argparse issueson May 19, 2022
  3. erlend-aasland
    moved this to Bugs in Argparse issueson May 19, 2022
  4. sobolevn
    self-assigned this
    on Apr 22, 2023
  5. sobolevn
    added a commit that references this issue on Apr 22, 2023

    pythongh-92248: Deprecate `type`, `chocies`, `metavar` parameters of …

    5524230
  6. hugovk
    added a commit that references this issue on May 19, 2023

    gh-92248: Deprecate `type`, `choices`, `metavar` parameters of `argpa…

    27a7d5e
  7. carljm
    added a commit that references this issue on May 20, 2023

    Merge branch 'main' into gsallam/main

    ea5965a
  8. hauntsaninja
    closed this as completedon May 26, 2023
  9. github-project-automation
    moved this from Bugs to Doc issues in Argparse issueson May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sobolevn
    sobolevn

Labels

type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

  • Argparse issues
    Status
    Doc issues
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.