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 array_api_compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"""
__version__ = '1.15.0.dev0'

from .common import * # noqa: F401, F403
from .common import * # noqa: F403
2 changes: 1 addition & 1 deletion array_api_compat/common/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def your_function(x, y):
# torch._dynamo.exc.Unsupported: Dynamo cannot determine whether the underlying object is hashable
# Explanation: Dynamo does not know whether the underlying python object for
# PythonModuleVariable(<module 'array_api_compat.torch' from ...) is hashable
names = set(x.__name__ for x in namespaces)
names = {x.__name__ for x in namespaces}
unique_namespaces = []
for ns in namespaces:
if (name := ns.__name__) in names:
Expand Down
2 changes: 1 addition & 1 deletion array_api_compat/cupy/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
__all__ = linalg_all + _linalg.__all__

# cupy 13 does not have __all__, cupy 14 has it: remove duplicates
__all__ = sorted(list(set(__all__)))
__all__ = sorted(set(__all__))

def __dir__() -> list[str]:
return __all__
1 change: 0 additions & 1 deletion array_api_compat/numpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# ruff: noqa: PLC0414
from typing import Final

from .._internal import clone_module
Expand Down
2 changes: 1 addition & 1 deletion array_api_compat/torch/_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def _axis_none_keepdims(x, ndim, keepdims):
# (https://github.com/pytorch/pytorch/issues/71209)
# Note that this is only valid for the axis=None case.
if keepdims:
for i in range(ndim):
for _ in range(ndim):
x = torch.unsqueeze(x, 0)
return x

Expand Down
20 changes: 10 additions & 10 deletions array_api_compat/torch/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def fftn(
x: Array,
/,
*,
s: Sequence[int] = None,
axes: Sequence[int] = None,
s: Sequence[int] | None = None,
axes: Sequence[int] | None = None,
norm: Literal["backward", "ortho", "forward"] = "backward",
**kwargs: object,
) -> Array:
Expand All @@ -28,8 +28,8 @@ def ifftn(
x: Array,
/,
*,
s: Sequence[int] = None,
axes: Sequence[int] = None,
s: Sequence[int] | None = None,
axes: Sequence[int] | None = None,
norm: Literal["backward", "ortho", "forward"] = "backward",
**kwargs: object,
) -> Array:
Expand All @@ -39,8 +39,8 @@ def rfftn(
x: Array,
/,
*,
s: Sequence[int] = None,
axes: Sequence[int] = None,
s: Sequence[int] | None = None,
axes: Sequence[int] | None = None,
norm: Literal["backward", "ortho", "forward"] = "backward",
**kwargs: object,
) -> Array:
Expand All @@ -50,8 +50,8 @@ def irfftn(
x: Array,
/,
*,
s: Sequence[int] = None,
axes: Sequence[int] = None,
s: Sequence[int] | None = None,
axes: Sequence[int] | None = None,
norm: Literal["backward", "ortho", "forward"] = "backward",
**kwargs: object,
) -> Array:
Expand All @@ -61,7 +61,7 @@ def fftshift(
x: Array,
/,
*,
axes: int | Sequence[int] = None,
axes: int | Sequence[int] | None = None,
**kwargs: object,
) -> Array:
return torch.fft.fftshift(x, dim=axes, **kwargs)
Expand All @@ -70,7 +70,7 @@ def ifftshift(
x: Array,
/,
*,
axes: int | Sequence[int] = None,
axes: int | Sequence[int] | None = None,
**kwargs: object,
) -> Array:
return torch.fft.ifftshift(x, dim=axes, **kwargs)
Expand Down
24 changes: 17 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,29 @@ namespaces = false
[tool.ruff.lint]
preview = true
select = [
# Defaults
"E4", "E7", "E9", "F",
# Undefined export
"F822",
# Useless import alias
"PLC0414"
# Defaults
"E4", "E7", "E9", "F",
# Additional rules
"B", "C4", "ISC", "PIE", "FLY", "PERF", "UP", "FURB",
# Useless import alias
"PLC0414",
# Unused `noqa` directive
"RUF100",
]

ignore = [
# Module import not at top of file
"E402",
# Do not use bare `except`
"E722"
"E722",
# Use of `functools.cache` on methods can lead to memory leaks
"B019",
# No explicit `stacklevel` keyword argument found
"B028",
# Within an `except` clause, raise exceptions with `raise ... from ...`
"B904",
# `try`-`except` within a loop incurs performance overhead
"PERF203",
]


Expand Down
2 changes: 1 addition & 1 deletion tests/test_isdtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def isdtype_(dtype_, kind):
res = dtype_categories[kind](dtype_)
else:
res = dtype_ == kind
assert type(res) is bool # noqa: E721
assert type(res) is bool
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the # noqa: E721 will cause Ruff to flag this line (E721 is included via the selected E7 rules). Either restore the noqa: E721 (optionally with a brief justification), or rewrite the assertion to avoid direct type(...) is ... comparison (e.g., use an isinstance-based check if that satisfies the intent).

Suggested change
assert type(res) is bool
assert isinstance(res, bool)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see ruff flagging this line.

With that said, this line could be modified as suggested, but the suggestion is orthogonal to this PR.

return res

@pytest.mark.parametrize("library", wrapped_libraries)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_no_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def _test_dependency(mod):
assert not is_mod_array(a)
assert mod not in sys.modules

is_array_api_obj = getattr(array_api_compat, "is_array_api_obj")
is_array_api_obj = array_api_compat.is_array_api_obj
assert is_array_api_obj(a)
assert mod not in sys.modules

array_namespace = getattr(array_api_compat, "array_namespace")
array_namespace = array_api_compat.array_namespace
array_namespace(Array())
assert mod not in sys.modules

Expand Down
Loading