Skip to content

Commit

Permalink
path: use class constants in checks
Browse files Browse the repository at this point in the history
instead of string literals, which would mean two places requried changing
  • Loading branch information
Cube707 committed Jun 21, 2024
1 parent ea71759 commit b8f9797
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/inquirer/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ def validate(self, current):

# os.path.isdir and isfile check also existence of the path,
# which might not be desirable
if self._path_type == "file":
if self._path_type == Path.FILE:
if self._exists is None and os.path.basename(current) == "":
raise errors.ValidationError(current)
elif self._exists and not os.path.isfile(current):
raise errors.ValidationError(current)
elif self._exists is not None and not self._exists and os.path.isfile(current):
raise errors.ValidationError(current)

elif self._path_type == "directory":
elif self._path_type == Path.DIRECTORY:
if self._exists is None and os.path.basename(current) != "":
raise errors.ValidationError(current)
elif self._exists and not os.path.isdir(current):
Expand Down

0 comments on commit b8f9797

Please sign in to comment.