Skip to content

Commit

Permalink
Fix issues with ruff and pre-commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauvilsa committed Oct 9, 2023
1 parent d91dda8 commit ba9c330
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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: []
Expand Down
2 changes: 1 addition & 1 deletion jsonargparse/_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
1 change: 1 addition & 0 deletions jsonargparse/_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ select = [
]
ignore = [
"E731", # Do not convert lambda assigns to a def
"E721", # Allow comparing types with type()
]

[tool.ruff.pydocstyle]
Expand Down

0 comments on commit ba9c330

Please sign in to comment.