Skip to content

Commit 355528b

Browse files
committed
pyright
1 parent 2bbf7bd commit 355528b

File tree

9 files changed

+30
-25
lines changed

9 files changed

+30
-25
lines changed

pixi.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ reportImportCycles = false
290290
reportUnknownLambdaType = false
291291

292292
executionEnvironments = [
293-
{ root = "tests", reportPrivateUsage = false },
293+
{ root = "tests", reportPrivateUsage = false, reportUnknownArgumentType = false },
294294
{ root = "src" },
295295
]
296296

tests/conftest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ def library(request: pytest.FixtureRequest) -> Backend: # numpydoc ignore=PR01,
3737
("xfail_xp_backend", partial(xfail, request), {"reason", "strict"}),
3838
):
3939
for marker in request.node.iter_markers(marker_name):
40-
if len(marker.args) != 1: # pyright: ignore[reportUnknownArgumentType]
40+
if len(marker.args) != 1:
4141
msg = f"Expected exactly one positional argument; got {marker.args}"
4242
raise TypeError(msg)
4343
if not isinstance(marker.args[0], Backend):
4444
msg = f"Argument of {marker_name} must be a Backend enum"
4545
raise TypeError(msg)
46-
if invalid_kwargs := set(marker.kwargs) - allow_kwargs: # pyright: ignore[reportUnknownArgumentType]
46+
if invalid_kwargs := set(marker.kwargs) - allow_kwargs:
4747
msg = f"Unexpected kwarg(s): {invalid_kwargs}"
4848
raise TypeError(msg)
4949

@@ -52,9 +52,9 @@ def library(request: pytest.FixtureRequest) -> Backend: # numpydoc ignore=PR01,
5252
strict: bool | None = marker.kwargs.get("strict", None)
5353

5454
if library == elem:
55-
reason = f"{library}: {reason}" if reason else str(library) # pyright: ignore[reportUnknownArgumentType]
55+
reason = f"{library}: {reason}" if reason else str(library)
5656
kwargs = {"strict": strict} if strict is not None else {}
57-
skip_or_xfail(reason=reason, **kwargs) # pyright: ignore[reportUnknownArgumentType]
57+
skip_or_xfail(reason=reason, **kwargs)
5858

5959
return elem
6060

@@ -98,7 +98,7 @@ def as_readonly(o: T) -> T: # numpydoc ignore=PR01,RT01
9898

9999
# This works with namedtuples too
100100
if isinstance(o, tuple | list):
101-
return type(o)(*(as_readonly(i) for i in o)) # type: ignore[arg-type,return-value] # pyright: ignore[reportArgumentType,reportUnknownArgumentType]
101+
return type(o)(*(as_readonly(i) for i in o)) # type: ignore[arg-type,return-value] # pyright: ignore[reportArgumentType]
102102

103103
return o
104104

tests/test_funcs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def test_broadcast(self, xp: ModuleType):
9494
actual = apply_where(
9595
cond,
9696
(x, y),
97-
lambda x, _: x, # pyright: ignore[reportUnknownArgumentType]
98-
lambda _, y: y, # pyright: ignore[reportUnknownArgumentType]
97+
lambda x, _: x,
98+
lambda _, y: y,
9999
)
100100
expect = xp.where(cond, x, y)
101101
xp_assert_equal(actual, expect)
@@ -115,7 +115,7 @@ def test_dtype_propagation(self, xp: ModuleType, library: Backend):
115115
cond,
116116
(x, y),
117117
self.f1,
118-
lambda x, y: mxp.astype(x - y, xp.int64), # pyright: ignore[reportArgumentType,reportUnknownArgumentType]
118+
lambda x, y: mxp.astype(x - y, xp.int64),
119119
)
120120
assert actual.dtype == xp.int64
121121

@@ -162,8 +162,8 @@ def test_dont_run_on_false(self, xp: ModuleType):
162162
actual = apply_where(
163163
x == 0,
164164
(x, y),
165-
lambda x, y: x / y, # pyright: ignore[reportUnknownArgumentType]
166-
lambda x, y: y / x, # pyright: ignore[reportUnknownArgumentType]
165+
lambda x, y: x / y,
166+
lambda x, y: y / x,
167167
)
168168
xp_assert_equal(actual, xp.asarray([0.0, 1.5, 0.0]))
169169

tests/test_helpers.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def test_device(self, xp: ModuleType, library: Backend, device: Device):
234234

235235
# Test that we're accepting anything that is accepted by the
236236
# device= parameter in other functions
237-
actual = capabilities(xp, device=device.type) # type: ignore[attr-defined] # pyright: ignore[reportUnknownArgumentType,reportAttributeAccessIssue]
237+
actual = capabilities(xp, device=device.type) # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue]
238238

239239

240240
class Wrapper(Generic[T]): # noqa: PLW1641
@@ -331,16 +331,16 @@ def test_flattened_stream(self):
331331
obj2 = [Wrapper(2), Wrapper(3)]
332332
instances1, rest1 = pickle_flatten(obj1, Wrapper)
333333
instances2, rest2 = pickle_flatten(obj2, Wrapper)
334-
it = iter(instances1 + instances2 + [Wrapper(4)]) # pyright: ignore[reportUnknownArgumentType]
335-
assert pickle_unflatten(it, rest1) == obj1 # pyright: ignore[reportUnknownArgumentType]
336-
assert pickle_unflatten(it, rest2) == obj2 # pyright: ignore[reportUnknownArgumentType]
337-
assert list(it) == [Wrapper(4)] # pyright: ignore[reportUnknownArgumentType]
334+
it = iter(instances1 + instances2 + [Wrapper(4)])
335+
assert pickle_unflatten(it, rest1) == obj1
336+
assert pickle_unflatten(it, rest2) == obj2
337+
assert list(it) == [Wrapper(4)]
338338

339339
def test_too_short(self):
340340
obj = [Wrapper(1), Wrapper(2)]
341341
instances, rest = pickle_flatten(obj, Wrapper)
342342
with pytest.raises(ValueError, match="Not enough"):
343-
pickle_unflatten(instances[:1], rest) # pyright: ignore[reportUnknownArgumentType]
343+
pickle_unflatten(instances[:1], rest)
344344

345345
def test_recursion(self):
346346
obj: list[object] = [Wrapper(1)]
@@ -349,7 +349,7 @@ def test_recursion(self):
349349
instances, rest = pickle_flatten(obj, Wrapper)
350350
assert instances == [Wrapper(1)]
351351

352-
obj2 = pickle_unflatten(instances, rest) # pyright: ignore[reportUnknownArgumentType]
352+
obj2 = pickle_unflatten(instances, rest)
353353
assert len(obj2) == 2
354354
assert obj2[0] is obj[0]
355355
assert obj2[1] is obj2
@@ -403,7 +403,7 @@ def f(x: object) -> object:
403403
assert isinstance(out, Wrapper)
404404
assert out.x[0] is winp.x[0]
405405
assert out.x[1] is not winp.x[1]
406-
xp_assert_equal(out.x[1], winp.x[1]) # pyright: ignore[reportUnknownArgumentType]
406+
xp_assert_equal(out.x[1], winp.x[1])
407407

408408
def test_arraylikes_are_static(self):
409409
pytest.importorskip("jax")

tests/test_lazy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ def f(x: Array) -> Array:
187187
return x + 1
188188

189189
y = lazy_apply(f, x_da)
190-
assert array_namespace(y._meta) is cp # type: ignore[attr-defined] # pyright: ignore[reportUnknownArgumentType,reportAttributeAccessIssue]
191-
xp_assert_equal(y.compute(), x_cp + 1) # type: ignore[attr-defined] # pyright: ignore[reportUnknownArgumentType,reportAttributeAccessIssue]
190+
assert array_namespace(y._meta) is cp # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue]
191+
xp_assert_equal(y.compute(), x_cp + 1) # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue]
192192

193193

194194
def test_dask_key(da: ModuleType):
@@ -396,7 +396,7 @@ def test_lazy_apply_kwargs(xp: ModuleType, library: Backend, as_numpy: bool):
396396
with numpy arrays, and leave the rest untouched."""
397397
x = xp.asarray(0)
398398
expect_cls = np.ndarray if as_numpy or library is Backend.DASK else type(x)
399-
actual = check_lazy_apply_kwargs(x, expect_cls, as_numpy) # pyright: ignore[reportUnknownArgumentType]
399+
actual = check_lazy_apply_kwargs(x, expect_cls, as_numpy)
400400
xp_assert_equal(actual, x + 1)
401401

402402

tests/test_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def test_lazy_xp_function_deprecated_static_argnames():
296296
# scipy.special.erf.
297297
from scipy.special._ufuncs import erf # type: ignore[import-untyped]
298298

299-
lazy_xp_function(erf) # pyright: ignore[reportUnknownArgumentType]
299+
lazy_xp_function(erf)
300300
except ImportError:
301301
erf = None
302302

vendor_tests/_array_api_compat_vendor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This file is a hook imported by `src/array_api_extra/_lib/_compat.py`."""
2+
# pyright: reportUnknownParameterType=false, reportMissingParameterType=false
23

34
from .array_api_compat import * # noqa: F403
45
from .array_api_compat import array_namespace as array_namespace_compat

vendor_tests/test_vendor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# pyright: reportAttributeAccessIssue=false
2+
3+
from typing import Any
4+
15
import array_api_strict as xp
26
from numpy.testing import assert_array_equal
37

@@ -59,7 +63,7 @@ def test_vendor_extra():
5963
def test_vendor_extra_testing():
6064
from .array_api_extra.testing import lazy_xp_function
6165

62-
def f(x):
66+
def f(x: Any) -> Any:
6367
return x
6468

6569
lazy_xp_function(f)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy