-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Expected Behavior
Tell us what should happen.
import os, click
@click.command()
@click.option('--output-stdout', 'output', flag_value='-')
@click.option('--output-default', 'output', flag_value='/path/to/default/output/location')
@click.option('-o', '--output', type=click.File('w'), default=None)
def edit(output):
click.echo(type(output))
click.echo(output)
edit()with --output option, the provided string should be (lazily) opened.
$ python e.py --output /path/to/file
<class 'click.utils.LazyFile'>
<unopened file '/path/to/file' w>Actual Behavior
Instead, it is still str
$ python e.py --output /path/to/file
<class 'str'>
/path/to/fileAlthough --output-stdout and --output-default works as expected.
$ python e.py --output-default
<class 'click.utils.LazyFile'>
<unopened file '/path/to/default/output/location' w>
$ python e.py --output-stdout
<class '_io.TextIOWrapper'>
<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>But if I put them after --output, they will not work too.
Environment
- Python version: Python 3.8.6
- Click version: click==7.1.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels