pallets / pallets/click

allow checking for path non-existance

Open
#1,428 5 comments 9 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

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.