diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8bd8744..abf0fcf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 ] diff --git a/dargs/dargs.py b/dargs/dargs.py index f067b01..eab2733 100644 --- a/dargs/dargs.py +++ b/dargs/dargs.py @@ -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: @@ -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, @@ -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) @@ -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) @@ -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: