Skip to content

Read false values of the command-line tool's environment variables as false - #184

Open
RavSinghChandan wants to merge 1 commit into
JoshData:mainfrom
RavSinghChandan:cli-false-environment-values
Open

RavSinghChandan wants to merge 1 commit into
JoshData:mainfrom
RavSinghChandan:cli-false-environment-values

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

The command-line tool sets each boolean option with bool(os.environ[varname]), so any non-empty value turns it on, including the values meant to turn it off:

CHECK_DELIVERABILITY=0 python -m email_validator me@example.com      # DNS checks still run
ALLOW_DOMAIN_LITERAL=false python -m email_validator me@[127.0.0.1]  # accepted

The only way to turn an option off was an empty value (CHECK_DELIVERABILITY=). 0, false, no and off (in any case) are now read as false too; an empty value is still false and every other value still true.

Added test_main_boolean_environment_variable (with ALLOW_DOMAIN_LITERAL set to true and false spellings); the false spellings fail before the fix. Changelog entry under In Development

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant