Skip to content

Commit

Permalink
Apply and enforce ruff/pyupgrade rules (UP)
Browse files Browse the repository at this point in the history
UP006 Use `tuple` instead of `Tuple` for type annotation

UP035 `typing.Dict` is deprecated, use `dict` instead
UP035 `typing.Tuple` is deprecated, use `tuple` instead
UP035 `typing.Type` is deprecated, use `type` instead
  • Loading branch information
DimitriPapadopoulos committed Aug 10, 2024
1 parent 1038a15 commit ba8e691
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions numcodecs/ndarray_like.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Protocol, Tuple, Type, runtime_checkable
from typing import Any, Optional, Protocol, runtime_checkable


class _CachedProtocolMeta(Protocol.__class__):
Expand All @@ -11,7 +11,7 @@ class _CachedProtocolMeta(Protocol.__class__):
isinstance checks using the object's class as the cache key.
"""

_instancecheck_cache: Dict[Tuple[Type, Type], bool] = {}
_instancecheck_cache: dict[tuple[type, type], bool] = {}

def __instancecheck__(self, instance):
key = (self, instance.__class__)
Expand Down Expand Up @@ -39,8 +39,8 @@ class FlagsObj(Protocol, metaclass=_CachedProtocolMeta):
@runtime_checkable
class NDArrayLike(Protocol, metaclass=_CachedProtocolMeta):
dtype: DType
shape: Tuple[int, ...]
strides: Tuple[int, ...]
shape: tuple[int, ...]
strides: tuple[int, ...]
ndim: int
size: int
itemsize: int
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,9 @@ environment = { DISABLE_NUMCODECS_AVX2=1, DISABLE_NUMCODECS_SSE2=1 }
[tool.ruff]
line-length = 100

[tool.ruff.lint]
extend-select = [ "UP" ]
ignore = ["UP007"]

[tool.ruff.format]
quote-style = "preserve"

0 comments on commit ba8e691

Please sign in to comment.