Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
Assignees
sobolevn
Labels
type-bugAn unexpected behavior, bug, or error
@samwyse

Description

@samwyse

This is an elaboration of issue#85039.

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

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

Metadata

Metadata

Assignees

Labels

type-bugAn unexpected behavior, bug, or error

Projects

Status

Doc issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp