diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b8a3a0c0..4f470b9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 @@ -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/ diff --git a/src/jobflow/core/flow.py b/src/jobflow/core/flow.py index 287950c7..3a8edb0d 100644 --- a/src/jobflow/core/flow.py +++ b/src/jobflow/core/flow.py @@ -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( diff --git a/src/jobflow/core/job.py b/src/jobflow/core/job.py index 4d0c9b3b..0aaab450 100644 --- a/src/jobflow/core/job.py +++ b/src/jobflow/core/job.py @@ -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: diff --git a/src/jobflow/core/maker.py b/src/jobflow/core/maker.py index d62ac357..8344f67a 100644 --- a/src/jobflow/core/maker.py +++ b/src/jobflow/core/maker.py @@ -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() diff --git a/src/jobflow/core/reference.py b/src/jobflow/core/reference.py index 10d774b3..4ec338a2 100644 --- a/src/jobflow/core/reference.py +++ b/src/jobflow/core/reference.py @@ -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, diff --git a/src/jobflow/utils/uid.py b/src/jobflow/utils/uid.py index 86ddd89c..8ef3ead4 100644 --- a/src/jobflow/utils/uid.py +++ b/src/jobflow/utils/uid.py @@ -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):