allow checking for path non-existance
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.7k
- Forks
- 2.3k
- Avg merge
- 1d 30m
- Merged PRs (30d)
- 18
Description
right now, using click.Path() allows a user to set the following params:
exists=True: aborts if path does not exists
dir_okay=False: aborts if path (exists and) is a dir
file_okay=False: aborts if path (exists and) is a file
(notice that for the each case, the opposite value will make the check to be simply skipped)
However, I believe that in many times, the programmer will want to write a program that verifies that a given path does not exists, (e.g. for purpose of creating it without overwriting anything)
for this case, I believe this set of parameters is better:
exists_okay=False: aborts if path exists
not_exists_okay=False: aborts if path does not exists
dir_okay=False: aborts if path (exists and) is a dir
file_okay=False: aborts if path (exists and) is a file
notice how before, users could think that exist=False will force the path to be non-existing, while now each parameter behavior is clear from it's name.
from a quick look at the code, making this change seems to be trivial.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the click.Path entry point and inspect how its existing exists, dir_okay, and file_okay checks are implemented and tested. Determine how a non-existence check should interact with those options, then add coverage showing the requested paths are accepted or rejected as intended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100