Skip to content

Commit aa99cd7

Browse files
authored
Merge pull request #195 from jorenham/ruff-0.8
`ruff 0.8.0` and `basedpyright 1.22.0`
2 parents ef6d11b + 62acbff commit aa99cd7

File tree

15 files changed

+118
-104
lines changed

15 files changed

+118
-104
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ jobs:
2424
plugins: sp-repo-review
2525

2626
- name: markdownlint
27-
uses: DavidAnson/markdownlint-cli2-action@v17
27+
uses: DavidAnson/markdownlint-cli2-action@v18
2828
with:
2929
config: ".markdownlint.yaml"
3030
globs: "**/*.md"
3131

3232
- name: Install uv
33-
uses: astral-sh/setup-uv@v3
33+
uses: astral-sh/setup-uv@v4
3434
with:
3535
enable-cache: true
3636

@@ -69,7 +69,7 @@ jobs:
6969
- uses: actions/checkout@v4
7070

7171
- name: setup uv
72-
uses: astral-sh/setup-uv@v3
72+
uses: astral-sh/setup-uv@v4
7373
with:
7474
enable-cache: true
7575

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ repos:
4747
- black==24.10.0
4848

4949
- repo: https://github.com/igorshubovych/markdownlint-cli
50-
rev: v0.42.0
50+
rev: v0.43.0
5151
hooks:
5252
- id: markdownlint
5353

@@ -59,7 +59,7 @@ repos:
5959
- tomli
6060

6161
- repo: https://github.com/astral-sh/ruff-pre-commit
62-
rev: v0.7.4
62+
rev: v0.8.0
6363
hooks:
6464
- id: ruff
6565
args: [--fix, --show-fixes]

examples/functor.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import sys
4-
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast, final
4+
from typing import TYPE_CHECKING, Generic, TypeVar, final
55
import optype as o
66

77
if sys.version_info >= (3, 12):
@@ -33,10 +33,10 @@ def map1(self, f: Callable[[_T_co], _Y], /) -> Functor[_Y]:
3333
"""
3434
return Functor(f(self.value))
3535

36-
def map2( # type: ignore[no-any-explicit]
36+
def map2(
3737
self,
3838
f: Callable[[_T_co, _X], _Y],
39-
other: Functor[_X] | Any,
39+
other: Functor[_X],
4040
/,
4141
) -> Functor[_Y] | NotImplementedType:
4242
"""
@@ -45,10 +45,6 @@ def map2( # type: ignore[no-any-explicit]
4545
is returned if `f` is not supported for the types, or if other is not
4646
a `Functor`.
4747
"""
48-
if not isinstance(other, Functor):
49-
return NotImplemented
50-
51-
other = cast(Functor[_X], other)
5248
y = f(self.value, other.value)
5349

5450
return NotImplemented if y is NotImplemented else Functor(y)

optype/_core/_can.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
_JustBoolT_co = TypeVar(
4949
"_JustBoolT_co",
50-
Literal[False], Literal[True], Literal[False, True], bool,
50+
Literal[False], Literal[True], Literal[False, True], bool, # noqa: RUF038
5151
covariant=True,
5252
default=bool,
5353
) # fmt: skip

optype/dlpack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __dlpack__( # type: ignore[no-any-explicit]
9292
dl_device: tuple[_TypeT_co, _DeviceT_co] | None = None,
9393
# NOTE: This should be `bool | None`, but because of an incorrect annotation in
9494
# `numpy.ndarray.__dlpack__`, this is not possible at the moment.
95-
copy: Any | None = None,
95+
copy: Any | None = None, # pyright: ignore[reportExplicitAny]
9696
) -> CapsuleType: ...
9797

9898

optype/inspect.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import inspect
55
import sys
66
from types import GenericAlias, UnionType
7-
from typing import TYPE_CHECKING, Any, Literal, cast, get_args as _get_args
7+
from typing import TYPE_CHECKING, Any, Literal, TypeAlias, cast, get_args as _get_args
88

99

1010
if sys.version_info >= (3, 13):
@@ -80,7 +80,7 @@ def is_iterable(obj: object, /) -> TypeIs[AnyIterable]:
8080

8181
# not all sequence-likes implement __len__, e.g. `ctypes.pointer`
8282
try:
83-
obj[0]
83+
obj[0] # pyright: ignore[reportArgumentType]
8484
except (IndexError, StopIteration):
8585
pass
8686
except (KeyError, ValueError, TypeError):
@@ -91,6 +91,9 @@ def is_iterable(obj: object, /) -> TypeIs[AnyIterable]:
9191
return False
9292

9393

94+
_AnyClassMethod: TypeAlias = "classmethod[Any, ..., object]" # pyright: ignore[reportExplicitAny]
95+
96+
9497
@overload
9598
def is_final(final_cls_or_method: WrappedFinalType, /) -> Literal[True]: ...
9699
@overload
@@ -101,7 +104,7 @@ def is_final(fn: CanCall[..., object], /) -> bool: ...
101104
def is_final(prop: property, /) -> bool: ...
102105
@overload
103106
def is_final(
104-
clsmethod: classmethod[Any, ..., object] | staticmethod[..., object],
107+
clsmethod: _AnyClassMethod | staticmethod[..., object],
105108
/,
106109
) -> bool: ...
107110
def is_final(
@@ -110,7 +113,7 @@ def is_final(
110113
| type
111114
| CanCall[..., object]
112115
| property
113-
| classmethod[Any, ..., object]
116+
| _AnyClassMethod
114117
| staticmethod[..., object]
115118
),
116119
/,

optype/numpy/_any_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class _AnyArrayPY0(Protocol[_T_co]):
8383
def __len__(self, /) -> int: ...
8484
def __getitem__(self, i: int, /) -> _T_co | _AnyArrayPY0[_T_co]: ...
8585
def __reversed__(self, /) -> Iterator[_T_co | _AnyArrayPY0[_T_co]]: ...
86-
def index(self, x: Any, /) -> int: ... # pyright: ignore[reportAny]
86+
def index(self, x: Any, /) -> int: ... # pyright: ignore[reportAny,reportExplicitAny]
8787

8888

8989
_AnyArrayPY: TypeAlias = tuple[_T, ...] | _AnyArrayPY0[_T]

optype/numpy/_scalar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __array__(self, dtype: _DT, /) -> _Array0D[_DT]: ...
105105

106106

107107
# `NBitBase` invariant and doesn't actually do anything, so the default should be `Any`
108-
_N = TypeVar("_N", bound=npt.NBitBase, default=Any)
108+
_N = TypeVar("_N", bound=npt.NBitBase, default=Any) # pyright: ignore[reportExplicitAny]
109109

110110
generic = np.generic
111111
flexible = np.flexible

optype/types/_typeforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class _C(Generic[_T]): ...
1818
AnnotatedAlias = type(Annotated[None, None])
1919

2020
# typing._LiteralGenericAlias
21-
LiteralAlias = type(Literal[None])
21+
LiteralAlias = type(Literal[0])
2222

2323
# typing._UnionGenericAlias
2424
# NOTE: this is not the same as `types.UnionType`!
25-
UnionAlias = type(Literal[None] | None)
25+
UnionAlias = type(Literal[0] | None)

optype/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class _EmptyTypedDict(TypedDict):
9696
EmptyIterable: TypeAlias = AnyIterable[Never]
9797

9898

99-
LiteralBool: TypeAlias = Literal[False, True]
99+
LiteralBool: TypeAlias = Literal[False, True] # noqa: RUF038
100100
LiteralByte: TypeAlias = Literal[
101101
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
102102
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,

0 commit comments

Comments
 (0)