pallets / pallets/click

for argument type File, `lazy` does not work on Windows

Open
#2,429 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

parsing
Dominant language
Python
Stars
17.7k
Forks
2.3k
Avg merge
1d 30m
Merged PRs (30d)
18

Description

@click.argument( "csv_file", default="goodreads_library_export.csv", type=click.File( "r", lazy=True, ), nargs=1, )

That work as expected in Linux - if I do not open the file it works even if there is no such file.
But in Windows it fails
https://github.com/andgineer/goodreads-export/actions/runs/3867907090/jobs/6593008354
`Usage: main [OPTIONS] [CSV_FILE]
Try 'main --help' for help.

Error: Invalid value for '[CSV_FILE]': 'goodreads_library_export.csv': No such file or directory`

Environment:

  • Python version: 3.9
  • Click version: 8.1.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Click 8.1.3 example with click.File("r", lazy=True) on Windows, then compare its argument validation with Linux behavior. Use the linked GitHub Actions run as the Windows failure reference; done means a nonexistent default path is accepted when the file is never opened, with coverage for the Windows case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.