Visitar URL original
Suggestion for argparse: raise a warning on type=bool · Issue #126676 · python/cpython · GitHub
Skip to content

Suggestion for argparse: raise a warning on type=bool #126676

Closed

Description

@user202729

Feature or enhancement

Proposal:

There has been complaints about type=bool usage in argparse: #81745 #83348 #71181 . See also https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse

while we may not want to actually change the behavior (given existing code on the wild might use it, as mentioned in previous discussions), what about raise a warning? Or is that also too intrusive?

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 11, 2024
  2. savannahostrowski commented on Nov 17, 2024

    @savannahostrowski
    Member

    I'd probably be more inclined to document recipes/patterns to achieve the desired result if we need additional materials here since we have already documented that bool() is not recommended as a type converter.

    The bool() function is not recommended as a type converter. All it does is convert empty strings to False and non-empty strings to True. This is usually not what is desired.

    My concern is that adding a warning here could still break tests, etc.

  3. added
    docsDocumentation in the Doc dir
    and removed
    type-featureA feature request or enhancement
    on Nov 17, 2024
  4. added a commit that references this issue on Mar 25, 2026
  5. added a commit that references this issue on Apr 3, 2026
  6. added 2 commits that reference this issue on Apr 3, 2026
  7. added 2 commits that reference this issue on Apr 3, 2026
  8. added a commit that references this issue on Apr 25, 2026
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

    docsDocumentation in the Doc direasystdlibStandard Library Python modules in the Lib/ directory

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions