Skip to content

Commit ff82f92

Browse files
authored
fix(config_file): allow directories in _path_validator (jxmorris12#192)
1 parent 8dc729b commit ff82f92

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

language_tool_python/config_file.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,19 @@ def _path_encoder(v: PathLike[str] | str) -> str:
141141

142142

143143
def _path_validator(v: PathLike[str] | str) -> None:
144-
"""Validate that a given path exists and is a file.
144+
"""Validate that a given path exists and is a file or directory.
145145
146146
:param v: The path to validate, which will be converted to a Path object
147147
:type v: PathLike[str] | str
148148
:raises PathError: If the path does not exist
149-
:raises PathError: If the path exists but is not a file
149+
:raises PathError: If the path exists but is not a file or directory
150150
"""
151151
p = Path(v)
152152
if not p.exists():
153153
err = f"path does not exist: {p}"
154154
raise PathError(err)
155-
if not p.is_file():
156-
err = f"path is not a file: {p}"
155+
if not p.is_file() and not p.is_dir():
156+
err = f"path is not a file/directory: {p}"
157157
raise PathError(err)
158158

159159

0 commit comments

Comments
 (0)