Skip to content

Commit

Permalink
Merge pull request #593 from materialsproject/ruff-fixes
Browse files Browse the repository at this point in the history
Bump `ruff` and fix errors
  • Loading branch information
janosh authored Apr 26, 2024
2 parents c9bda78 + 7215d42 commit 17a20f6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ default_language_version:
exclude: "^src/atomate2/vasp/schemas/calc_types/"
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.4
rev: v0.4.2
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: fix-encoding-pragma
Expand All @@ -23,7 +23,7 @@ repos:
additional_dependencies: [black]
exclude: ^(README.md|paper/paper.md)$
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
entry: pflake8
Expand All @@ -43,7 +43,7 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
rev: v1.10.0
hooks:
- id: mypy
files: ^src/
Expand Down
5 changes: 2 additions & 3 deletions src/jobflow/core/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ def __setitem__(
self, idx: int | slice, value: Flow | Job | Sequence[Flow | Job]
) -> None:
"""Set the job(s) or subflow(s) at the given index/slice."""
if (
not isinstance(value, (Flow, jobflow.Job, tuple, list))
or isinstance(value, (tuple, list))
if not isinstance(value, (Flow, jobflow.Job, tuple, list)) or (
isinstance(value, (tuple, list))
and not all(isinstance(v, (Flow, jobflow.Job)) for v in value)
):
raise TypeError(
Expand Down
4 changes: 2 additions & 2 deletions src/jobflow/core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,8 @@ def add_hosts_uuids(self, hosts_uuids: str | Sequence[str], prepend: bool = Fals
prepend
Insert the UUIDs at the beginning of the list rather than extending it.
"""
if not isinstance(hosts_uuids, (list, tuple)):
hosts_uuids = [hosts_uuids] # type: ignore
if isinstance(hosts_uuids, str):
hosts_uuids = [hosts_uuids]
if prepend:
self.hosts[0:0] = hosts_uuids
else:
Expand Down
4 changes: 1 addition & 3 deletions src/jobflow/core/maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ def _filter(nested_obj: Maker):
return False
if name_filter is not None and name_filter not in nested_obj.name:
return False
if class_filter is not None and not isinstance(nested_obj, class_filter):
return False
return True
return class_filter is None or isinstance(nested_obj, class_filter)

d = obj.as_dict()

Expand Down
2 changes: 1 addition & 1 deletion src/jobflow/core/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class OutputReference(MSONable):
OutputReference(1234, ['key'], [0], .value)
"""

__slots__ = ("uuid", "attributes", "output_schema")
__slots__ = ("attributes", "output_schema", "uuid")

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion src/jobflow/utils/uid.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Install it with `pip install jobflow[ulid]` or `pip install python-ulid`."
)

class ULID: # type: ignore
class ULID: # type: ignore[no-redef]
"""Fake ULID class for raising import error."""

def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit 17a20f6

Please sign in to comment.