Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: check-toml
# Python
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.2
rev: v0.16.0
hooks:
- id: ruff
args: [ --fix ]
Expand Down
10 changes: 5 additions & 5 deletions dargs/dargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ArgumentError(Exception):
"""Base error class for invalid argument values in argchecking."""

def __init__(
self, path: None | str | list[str] = None, message: str | None = None
self, path: str | list[str] | None = None, message: str | None = None
) -> None:
super().__init__(message)
if path is None:
Expand Down Expand Up @@ -142,7 +142,7 @@ class Argument:
def __init__(
self,
name: str,
dtype: None | type | Iterable[type | Any | None],
dtype: type | Iterable[type | Any | None] | None,
sub_fields: Iterable[Argument] | None = None,
sub_variants: Iterable[Variant] | None = None,
repeat: bool = False,
Expand Down Expand Up @@ -222,7 +222,7 @@ def I(self) -> Argument: # noqa:E743
return Argument("_", dict, [self])

def _reorg_dtype(
self, dtype: None | type | Any | Iterable[type | Any | None]
self, dtype: type | Any | Iterable[type | Any | None] | None
) -> tuple[type | Any | None, ...]:
if (
isinstance(dtype, type)
Expand Down Expand Up @@ -258,7 +258,7 @@ def _reorg_dtype(
# and make it compatible with `isinstance`
return tuple(dtype)

def set_dtype(self, dtype: None | type | Iterable[type]) -> None:
def set_dtype(self, dtype: type | Iterable[type] | None) -> None:
"""Change the dtype of the current Argument."""
self.dtype = self._reorg_dtype(dtype)

Expand Down Expand Up @@ -866,7 +866,7 @@ def extend_choices(self, choices: Iterable[Argument] | None) -> None:
def add_choice(
self,
tag: str | Argument,
_dtype: None | type | Iterable[type] = dict,
_dtype: type | Iterable[type] | None = dict,
*args: Any,
**kwargs: Any,
) -> Argument:
Expand Down