diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3b927dbe..5ef2d666 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.291 + rev: v0.0.292 hooks: - id: ruff args: ["--fix"] @@ -40,7 +40,7 @@ repos: - id: yesqa - repo: https://github.com/crate-ci/typos - rev: v1.16.14 + rev: v1.16.17 hooks: - id: typos args: [] diff --git a/jsonargparse/_namespace.py b/jsonargparse/_namespace.py index f6977c90..929797ab 100644 --- a/jsonargparse/_namespace.py +++ b/jsonargparse/_namespace.py @@ -127,7 +127,7 @@ def __init__(self, *args, **kwargs): else: if len(kwargs) != 0 or len(args) != 1 or not isinstance(args[0], (argparse.Namespace, dict)): raise ValueError("Expected a single positional parameter of type Namespace or dict.") - for key, val in args[0].items() if type(args[0]) is dict else vars(args[0]).items(): + for key, val in args[0].items() if isinstance(args[0], dict) else vars(args[0]).items(): self[key] = val def _parse_key(self, key: str) -> Tuple[str, Optional["Namespace"], str]: diff --git a/jsonargparse/_typehints.py b/jsonargparse/_typehints.py index ed726527..b5436914 100644 --- a/jsonargparse/_typehints.py +++ b/jsonargparse/_typehints.py @@ -470,6 +470,7 @@ def _check_type(self, value, append=False, cfg=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" try: if isinstance(orig_val, str): with change_to_path_dir(config_path): diff --git a/pyproject.toml b/pyproject.toml index d71e4428..c41f7060 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -173,6 +173,7 @@ select = [ ] ignore = [ "E731", # Do not convert lambda assigns to a def + "E721", # Allow comparing types with type() ] [tool.ruff.pydocstyle]