You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the --debug optionDEBUG environment variable in the sample command, the debug value is not correctly set (flag_value). It is expected to be either logging.DEBUG or None, but it seems to be getting the integer value directly from the environment variable.
Sample:
importloggingimportosimportsysimportclick# Works as expected# sys.argv = ['', '--debug']# Does not work as expected# os.environ['DEBUG'] = '1'@click.command()@click.option('--debug', is_flag=True, flag_value=logging.DEBUG, envvar='DEBUG')defsample(debug):
click.echo(f"DEBUG: {debug}")
assertdebugin [logging.DEBUG, None], f"Invalid debug value: {debug} - expected >{logging.DEBUG}< or None"if__name__=='__main__':
sample()
There is no different in using os.environ or DEBUG=1 python cli.py.
DEBUG=8 python cli.py prints out: 8
Environment:
Python version: 3.12.4
Click version: 8.1.7
The text was updated successfully, but these errors were encountered:
When using the
--debug optionDEBUG
environment variable in the sample command, the debug value is not correctly set (flag_value
). It is expected to be eitherlogging.DEBUG
orNone
, but it seems to be getting the integer value directly from the environment variable.Sample:
There is no different in using
os.environ
orDEBUG=1 python cli.py
.DEBUG=8 python cli.py
prints out:8
Environment:
The text was updated successfully, but these errors were encountered: