diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cdded131..fee9d663 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/DOCUMENTATION.rst b/DOCUMENTATION.rst index eab7fff1..de9bf7dd 100644 --- a/DOCUMENTATION.rst +++ b/DOCUMENTATION.rst @@ -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. diff --git a/jsonargparse/_actions.py b/jsonargparse/_actions.py index b9caf7ed..990cc472 100644 --- a/jsonargparse/_actions.py +++ b/jsonargparse/_actions.py @@ -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) diff --git a/jsonargparse/_core.py b/jsonargparse/_core.py index db7d2ce2..18f93371 100644 --- a/jsonargparse/_core.py +++ b/jsonargparse/_core.py @@ -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. diff --git a/jsonargparse/_paths.py b/jsonargparse/_paths.py index 3065a0bd..7cad60e2 100644 --- a/jsonargparse/_paths.py +++ b/jsonargparse/_paths.py @@ -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. @@ -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): @@ -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): @@ -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}") diff --git a/jsonargparse/_typehints.py b/jsonargparse/_typehints.py index f008d172..fcf190e3 100644 --- a/jsonargparse/_typehints.py +++ b/jsonargparse/_typehints.py @@ -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: diff --git a/jsonargparse/typing.py b/jsonargparse/typing.py index e2b10e75..51d28141 100644 --- a/jsonargparse/typing.py +++ b/jsonargparse/typing.py @@ -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)