The default value of an option with type click.File() is shown as the repr value of the opened file if the file exists. If the default file does not exist, the filename is shown. This is a regression from click version 7.1.2 where the help text always shows the file name.
Create the following minimal program as click-file-open-default:
# first run while the default file does not exist. This is the expected output
$ ./click-file-option-default --help
Usage: click-file-option-default [OPTIONS]
Options:
--file-opt FILENAME [default: my-file]
--help Show this message and exit. [default: False]
# create the file
$ touch my-file
# run the same command again. The default value in the help output changed.
$ ./click-file-option-default --help
Usage: click-file-option-default [OPTIONS]
Options:
--file-opt FILENAME [default: <_io.TextIOWrapper name='my-file' mode='r'
encoding='UTF-8'>]
--help Show this message and exit. [default: False]
I would expect the help text to show the filename (literal value of the default option).
The default value of an option with type
click.File()
is shown as the repr value of the opened file if the file exists. If the default file does not exist, the filename is shown. This is a regression from click version 7.1.2 where the help text always shows the file name.Create the following minimal program as
click-file-open-default
:Running the program:
I would expect the help text to show the filename (literal value of the default option).
Environment: