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 accept and silently discard its the const argument · Issue #85039 · python/cpython

argparse.BooleanOptionalAction accept and silently discard its the const argument #85039

New issue
Copy link
New issue
Copy link
Closed
Closed
argparse.BooleanOptionalAction accept and silently discard its the const argument#85039
Copy link
Labels
3.10 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory

Description

remilapeyre
mannequin
opened on Jun 4, 2020
Issue body actions
BPO 40862
Nosy @rhettinger, @miss-islington, @remilapeyre
PRs
  • bpo-40862: Raise TypeError when const is given to argparse.BooleanOptionalAction #20623
  • [3.9] bpo-40862: Raise TypeError when const is given to argparse.BooleanOptionalAction (GH-20623) #20664
  • 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 2020-06-06.02:31:45.829>
    created_at = <Date 2020-06-04.11:59:48.464>
    labels = ['library', '3.9', '3.10']
    title = 'argparse.BooleanOptionalAction accept and silently discard its the const argument'
    updated_at = <Date 2020-06-07.16:22:59.941>
    user = 'https://github.com/remilapeyre'

    bugs.python.org fields:

    activity = <Date 2020-06-07.16:22:59.941>
    actor = 'paul.j3'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-06-06.02:31:45.829>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2020-06-04.11:59:48.464>
    creator = 'remi.lapeyre'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40862
    keywords = ['patch']
    message_count = 6.0
    messages = ['370703', '370772', '370776', '370777', '370792', '370811']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'paul.j3', 'miss-islington', 'remi.lapeyre']
    pr_nums = ['20623', '20664']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue40862'
    versions = ['Python 3.9', 'Python 3.10']

    Activity

    1. remilapeyre commented on Jun 4, 2020

      @remilapeyre
      remilapeyremannequin
      on Jun 4, 2020
      MannequinAuthor
      More actions

      The action is used to store None, True or False when an argument like --foo or --no-foo is given to the cli so it has no used for this action, but it is accepted without warning:

      Python 3.10.0a0 (heads/bpo-wip:6e23a9c82b, Jun  4 2020, 13:41:35) 
      [Clang 11.0.3 (clang-1103.0.32.62)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import argparse
      >>> parser = argparse.ArgumentParser()
      >>> parser.add_argument('--foo', const='this_is_not_used', action=argparse.BooleanOptionalAction)
      BooleanOptionalAction(option_strings=['--foo', '--no-foo'], dest='foo', nargs=0, const=None, default=None, type=None, choices=None, help=None, metavar=None)
      >>> args = parser.parse_args()
      >>> args
      Namespace(foo=None)

      We could either always refuse this argument, or accepted and raise ValueError if it is different than None. The attached PR does the first.

    2. remilapeyre
      added
      3.9 (EOL)end of lifeend of life
      3.10 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      on Jun 4, 2020
    3. remilapeyre
      changed the title [-]argparse.BooleanOptionalAction accept and silently its the const argument[/-] [+]argparse.BooleanOptionalAction accept and silently discard its the const argument[/+] on Jun 4, 2020
    4. remilapeyre
      changed the title [-]argparse.BooleanOptionalAction accept and silently its the const argument[/-] [+]argparse.BooleanOptionalAction accept and silently discard its the const argument[/+] on Jun 4, 2020
    5. rhettinger commented on Jun 5, 2020

      @rhettinger
      rhettinger
      on Jun 5, 2020
      Contributor
      More actions

      ISTM this should be addressed through documentation rather than by breaking currently deployed code that may have specified a default that already matches what the action does.

    6. remilapeyre commented on Jun 5, 2020

      @remilapeyre
      remilapeyremannequin
      on Jun 5, 2020
      MannequinAuthor
      More actions

      argparse.BooleanOptionalAction was introduced in Python3.9 so there is no code there should be no code that already rely on it.

    7. rhettinger commented on Jun 5, 2020

      @rhettinger
      rhettinger
      on Jun 5, 2020
      Contributor
      More actions

      Right. Go ahead :-)

    8. rhettinger commented on Jun 5, 2020

      @rhettinger
      rhettinger
      on Jun 5, 2020
      Contributor
      More actions

      New changeset b084d1b by Rémi Lapeyre in branch 'master':
      bpo-40862: Raise TypeError when const is given to argparse.BooleanOptionalAction (GH-20623)
      b084d1b

    9. rhettinger commented on Jun 6, 2020

      @rhettinger
      rhettinger
      on Jun 6, 2020
      Contributor
      More actions

      New changeset d5e7348 by Miss Islington (bot) in branch '3.9':
      bpo-40862: Raise TypeError when const is given to argparse.BooleanOptionalAction (GH-20623) (GH-20664)
      d5e7348

    10. rhettinger
      closed this as completedon Jun 6, 2020
    11. rhettinger
      closed this as completedon Jun 6, 2020
    12. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory

      Projects

      No projects

        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.