Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ repos:
exclude: .bumpversion.cfg

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.8
rev: v0.15.10
hooks:
- id: ruff-check
- id: ruff-format

- repo: https://github.com/crate-ci/typos
rev: v1.42.1
rev: v1.45.0
hooks:
- id: typos
args: []
verbose: true

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
rev: v1.20.0
hooks:
- id: mypy
files: jsonargparse.*/.*.py
Expand Down
8 changes: 4 additions & 4 deletions DOCUMENTATION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,12 @@ included in the YAML file, or the corresponding absolute path:
'/.../app/data/info.db'

Likewise directories can be parsed using the :class:`.Path_dw` type, which would
require a directory to exist and be writeable. New path types can be created
require a directory to exist and be writable. New path types can be created
using the :func:`.path_type` function. For example to create a type for files
that must exist and be both readable and writeable, the command would be
that must exist and be both readable and writable, the command would be
``Path_frw = path_type('frw')``. If the file ``app/config.yaml`` is not
writeable, then using the type to cast ``Path_frw('app/config.yaml')`` would
raise a *TypeError: File is not writeable* exception. For more information of
writable, then using the type to cast ``Path_frw('app/config.yaml')`` would
raise a *TypeError: File is not writable* exception. For more information of
all the mode flags supported, refer to the documentation of the :class:`.Path`
class.

Expand Down
2 changes: 1 addition & 1 deletion jsonargparse/_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def apply_config(parser, cfg, dest, value) -> None:
raise ex_path
cfg_path = None
cfg_file = parser.parse_string(value, **kwargs)
except (TypeError, ValueError) + get_loader_exceptions() as ex_str: # type: ignore[misc]
except (TypeError, ValueError) + get_loader_exceptions() as ex_str:
raise TypeError(f'Parser key "{dest}": {ex_str}') from ex_str
else:
cfg_file = parser.parse_path(value, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion jsonargparse/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ def instantiate_classes(
cfg: Namespace,
instantiate_groups: bool = True,
) -> Namespace:
"""Recursively instantiates all subclasses defined by ``class_path``+``init_args`` and class groups.
"""Recursively instantiates all subclasses defined by ``class_path`` + ``init_args`` and class groups.

Args:
cfg: The configuration object to use.
Expand Down
12 changes: 6 additions & 6 deletions jsonargparse/_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ class Path(PathDeprecations):

When a Path instance is created, it is checked that: the path exists,
whether it is a file or directory and whether it has the required access
permissions (f=file, d=directory, r=readable, w=writeable, x=executable,
permissions (f=file, d=directory, r=readable, w=writable, x=executable,
c=creatable, u=url, s=fsspec or in uppercase meaning not, i.e., F=not-file,
D=not-directory, R=not-readable, W=not-writeable and X=not-executable).
D=not-directory, R=not-readable, W=not-writable and X=not-executable).

The creatable flag "c" can be given one or two times. If given once, the
parent directory must exist and be writeable. If given twice, the parent
parent directory must exist and be writable. If given twice, the parent
directory does not have to exist, but should be allowed to create.

An instance of Path class can also refer to the standard input or output.
Expand Down Expand Up @@ -204,7 +204,7 @@ def __init__(
if not os.path.isdir(pdir):
raise PathError(f"{ptype} is not creatable since parent directory does not exist: {abs_path!r}")
if not os.access(pdir, os.W_OK):
raise PathError(f"{ptype} is not creatable since parent directory not writeable: {abs_path!r}")
raise PathError(f"{ptype} is not creatable since parent directory not writable: {abs_path!r}")
if "d" in mode and os.access(abs_path, os.F_OK) and not os.path.isdir(abs_path):
raise PathError(f"{ptype} is not creatable since path already exists: {abs_path!r}")
if "f" in mode and os.access(abs_path, os.F_OK) and not os.path.isfile(abs_path):
Expand All @@ -220,7 +220,7 @@ def __init__(
if "r" in mode and not os.access(abs_path, os.R_OK):
raise PathError(f"{ptype} is not readable: {abs_path!r}")
if "w" in mode and not os.access(abs_path, os.W_OK):
raise PathError(f"{ptype} is not writeable: {abs_path!r}")
raise PathError(f"{ptype} is not writable: {abs_path!r}")
if "x" in mode and not os.access(abs_path, os.X_OK):
raise PathError(f"{ptype} is not executable: {abs_path!r}")
if "D" in mode and os.path.isdir(abs_path):
Expand All @@ -230,7 +230,7 @@ def __init__(
if "R" in mode and os.access(abs_path, os.R_OK):
raise PathError(f"{ptype} is readable: {abs_path!r}")
if "W" in mode and os.access(abs_path, os.W_OK):
raise PathError(f"{ptype} is writeable: {abs_path!r}")
raise PathError(f"{ptype} is writable: {abs_path!r}")
if "X" in mode and os.access(abs_path, os.X_OK):
raise PathError(f"{ptype} is executable: {abs_path!r}")

Expand Down
1 change: 0 additions & 1 deletion jsonargparse/_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ def _check_type(self, value, append=False, cfg=None, mode=None):
with change_to_path_dir(config_path):
val = adapt_typehints(val, self._typehint, **kwargs)
except ValueError as ex:
assert ex # needed due to ruff bug that removes " as ex"
if orig_val == "-" and isinstance(getattr(ex, "parent", None), PathError):
raise ex
try:
Expand Down
4 changes: 2 additions & 2 deletions jsonargparse/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ def add_type(type_class: type, uniqueness_key: Optional[tuple], type_check: Opti

Path_fr = path_type("fr", docstring="path to a file that exists and is readable")
Path_fc = path_type("fc", docstring="path to a file that can be created if it does not exist")
Path_dw = path_type("dw", docstring="path to a directory that exists and is writeable")
Path_dw = path_type("dw", docstring="path to a directory that exists and is writable")
Path_dc = path_type("dc", docstring="path to a directory that can be created if it does not exist")
Path_drw = path_type("drw", docstring="path to a directory that exists and is readable and writeable")
Path_drw = path_type("drw", docstring="path to a directory that exists and is readable and writable")

register_type(os.PathLike, str, str)
register_type(complex)
Expand Down
Loading