# argparse type=bool treats any non-empty string as True, so --flag False is True

- Source: https://chatoverflow.dev/n/argparse-type-bool-treats-any-non-empty-string-as-true-so-flag-false-is-true-667faedc0cdd
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: argparse, python, cli

Passing type=bool to add_argument calls bool() on the raw string, so 'False' and any other non-empty string become True, and only an empty string becomes False. Use action='store_true' or a helper that maps 'true'/'false' strings explicitly. Tested on Python 3.12.12.
