Skip to content
Merged
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
4 changes: 2 additions & 2 deletions arraycontext/container/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from pytools.obj_array import (
ObjectArray,
# for backward compatibility
ObjectArray as NumpyObjectArray, # noqa: F401 # pyright: ignore[reportUnusedImport]
ObjectArray as NumpyObjectArray, # ruff:ignore[unused-import] # pyright: ignore[reportUnusedImport]
)

from arraycontext.container import (
Expand Down Expand Up @@ -740,7 +740,7 @@ def {fname}(arg2, arg1):
code = gen.get().rstrip()+"\n"

result_dict = {"_MODULE_SOURCE_CODE": code, "cls": cls}
exec(compile(code, f"<container arithmetic for {cls.__name__}>", "exec"), # noqa: S102
exec(compile(code, f"<container arithmetic for {cls.__name__}>", "exec"), # ruff:ignore[exec-builtin]
result_dict)

return cls
Expand Down
2 changes: 1 addition & 1 deletion arraycontext/container/dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _deserialize_init_arrays_code_{lower_cls_name}(
""")

exec_dict = {"cls": cls, "_MODULE_SOURCE_CODE": serialize_code}
exec(compile(serialize_code, f"<container serialization for {cls.__name__}>", # noqa: S102
exec(compile(serialize_code, f"<container serialization for {cls.__name__}>", # ruff:ignore[exec-builtin]
"exec"), exec_dict)

return cls
Expand Down
4 changes: 2 additions & 2 deletions arraycontext/container/traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def rec(*args_: Any) -> Any:
except NotAnArrayContainerError:
return f(*args_)

if __debug__: # noqa: SIM102
if __debug__: # ruff:ignore[collapsible-if]
if not all(
type(args_[i]) is type(template_ary)
for i in container_indices[1:]
Expand Down Expand Up @@ -1039,7 +1039,7 @@ def _unflatten(

# {{{ check strides

if strict and hasattr(template_subary_c, "strides"): # noqa: SIM102
if strict and hasattr(template_subary_c, "strides"): # ruff:ignore[collapsible-if]
# Checking strides for 0 sized arrays is ill-defined
# since they cannot be indexed
if (
Expand Down
6 changes: 3 additions & 3 deletions arraycontext/impl/pytato/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _preprocess_array_tags(tags: ToTagSetConvertible) -> frozenset[Tag]:
# }}}


class _NotOnlyDataWrappers(Exception): # noqa: N818
class _NotOnlyDataWrappers(Exception): # ruff:ignore[error-suffix-on-exception-name]
pass


Expand Down Expand Up @@ -858,7 +858,7 @@ def preprocess_arg(name, arg):
f"array type: got '{type(arg).__name__}', but expected one "
f"of {self.array_types}")

if name is not None: # noqa: SIM102
if name is not None: # ruff:ignore[collapsible-if]
# Tagging Placeholders with naming-related tags is pointless:
# They already have names. It's also counterproductive, as
# multiple placeholders with the same name that are not
Expand Down Expand Up @@ -1122,7 +1122,7 @@ def preprocess_arg(name: str | None, arg: Array):
f"array type: got '{type(arg).__name__}', but expected one "
f"of {self.array_types}")

if name is not None: # noqa: SIM102
if name is not None: # ruff:ignore[collapsible-if]
# Tagging Placeholders with naming-related tags is pointless:
# They already have names. It's also counterproductive, as
# multiple placeholders with the same name that are not
Expand Down
2 changes: 1 addition & 1 deletion arraycontext/impl/pytato/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _get_arg_id_to_arg_and_arg_id_to_descr(args: tuple[Any, ...],
arg_id_to_descr[arg_id] = ScalarInputDescriptor(np.dtype(type(arg)))
elif is_array_container_type(arg.__class__):
def id_collector(keys, ary):
arg_id = (kw, *keys) # noqa: B023
arg_id = (kw, *keys) # ruff:ignore[function-uses-loop-variable]
arg_id_to_arg[arg_id] = ary
arg_id_to_descr[arg_id] = LeafArrayDescriptor(
np.dtype(ary.dtype), ary.shape)
Expand Down
2 changes: 1 addition & 1 deletion arraycontext/impl/pytato/outline.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def id_collector(
pass
else:
assert isinstance(ary, pt.Array)
arg_id = (kw, *keys) # noqa: B023
arg_id = (kw, *keys) # ruff:ignore[function-uses-loop-variable]
arg_id_to_arg[arg_id] = ary
return ary

Expand Down
12 changes: 6 additions & 6 deletions arraycontext/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, device: cl.Device) -> None:
@override
def is_available(cls) -> bool:
try:
import pyopencl # noqa: F401 # pyright: ignore[reportUnusedImport]
import pyopencl # ruff:ignore[unused-import] # pyright: ignore[reportUnusedImport]
except ImportError:
return False
else:
Expand Down Expand Up @@ -154,8 +154,8 @@ class _PytestPytatoPyOpenCLArrayContextFactory(PytestPyOpenCLArrayContextFactory
@override
def is_available(cls) -> bool:
try:
import pyopencl # noqa: F401 # pyright: ignore[reportUnusedImport]
import pytato # noqa: F401 # pyright: ignore[reportUnusedImport]
import pyopencl # ruff:ignore[unused-import] # pyright: ignore[reportUnusedImport]
import pytato # ruff:ignore[unused-import] # pyright: ignore[reportUnusedImport]
except ImportError:
return False
else:
Expand Down Expand Up @@ -204,7 +204,7 @@ def __init__(self, *args, **kwargs) -> None:
@override
def is_available(cls) -> bool:
try:
import jax # noqa: F401 # pyright: ignore[reportUnusedImport]
import jax # ruff:ignore[unused-import] # pyright: ignore[reportUnusedImport]
except ImportError:
return False
else:
Expand Down Expand Up @@ -232,8 +232,8 @@ def __init__(self, *args, **kwargs) -> None:
@override
def is_available(cls) -> bool:
try:
import jax # noqa: F401 # pyright: ignore[reportUnusedImport]
import pytato # noqa: F401 # pyright: ignore[reportUnusedImport]
import jax # ruff:ignore[unused-import] # pyright: ignore[reportUnusedImport]
import pytato # ruff:ignore[unused-import] # pyright: ignore[reportUnusedImport]
except ImportError:
return False
else:
Expand Down
2 changes: 1 addition & 1 deletion arraycontext/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def reshape(self, *shape: int, order: OrderCF = "C") -> Array: ...
def reshape(self, shape: tuple[int, ...], /, *, order: OrderCF = "C") -> Array: ...

@property
def T(self) -> Array: ... # noqa: N802
def T(self) -> Array: ... # ruff:ignore[invalid-function-name]

def transpose(self, axes: tuple[int, ...]) -> Array: ...

Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@


def setup(app):
app.connect("missing-reference", process_autodoc_missing_reference) # noqa: F821
app.connect("missing-reference", process_autodoc_missing_reference) # ruff:ignore[undefined-name]
2 changes: 1 addition & 1 deletion examples/stub.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import arraycontext # noqa
import arraycontext # ruff:ignore[unused-import, missing-required-import]
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ extend-select = [
]
extend-ignore = [
"C90", # McCabe complexity
"E221", # multiple spaces before operator
"E226", # missing whitespace around arithmetic operator
"E402", # module-level import not at top of file
"RUF067", # non-empty-init-module
"TRY300",
"TRY004",
"multiple-spaces-before-operator",
"missing-whitespace-around-arithmetic-operator",
"module-import-not-at-top-of-file",
"non-empty-init-module",
"try-consider-else",
"type-check-without-type-error",
]

[tool.ruff.lint.flake8-quotes]
Expand All @@ -124,11 +124,11 @@ lines-after-imports = 2
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.per-file-ignores]
"doc/conf.py" = ["I002", "S102"]
"doc/conf.py" = ["missing-required-import", "exec-builtin"]
# To avoid a requirement of array container definitions being someplace importable
# from @dataclass_array_container.
"test/test_utils.py" = ["I002"]
"test/*.py" = ["S102"]
"test/test_utils.py" = ["missing-required-import"]
"test/*.py" = ["exec-builtin"]

[tool.typos.default]
extend-ignore-re = [
Expand Down
4 changes: 2 additions & 2 deletions test/test_arraycontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ def test_array_context_np_like(

if sym_name == "zeros_like":
if np.isscalar(result):
assert result == 0.0 # noqa: RUF069
assert result == 0.0 # ruff:ignore[float-equality-comparison]
else:
assert actx.to_numpy(actx.np.all(actx.np.equal(result, 0.0)))
elif sym_name == "ones_like":
if np.isscalar(result):
assert result == 1.0 # noqa: RUF069
assert result == 1.0 # ruff:ignore[float-equality-comparison]
else:
assert actx.to_numpy(actx.np.all(actx.np.equal(result, 1.0)))
else:
Expand Down
6 changes: 3 additions & 3 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# deprecated types are used.

import logging
from typing import ( # noqa: UP035
from typing import ( # ruff:ignore[deprecated-import]
ClassVar,
Optional, # pyright: ignore[reportDeprecated]
Tuple, # pyright: ignore[reportDeprecated]
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_dataclass_array_container() -> None:
class ArrayContainerWithOptional:
x: np.ndarray
# Deliberately left as Optional to test compatibility.
y: Optional[np.ndarray] # noqa: UP045 # pyright: ignore[reportDeprecated]
y: Optional[np.ndarray] # ruff:ignore[non-pep604-annotation-optional] # pyright: ignore[reportDeprecated]

with pytest.raises(TypeError, match=r"Field 'y':.*non-homogeneous.*"):
# NOTE: cannot have wrapped annotations (here by `Optional`)
Expand All @@ -86,7 +86,7 @@ class ArrayContainerWithOptional:
class ArrayContainerWithTuple:
x: Array
# Deliberately left as Tuple to test compatibility.
y: Tuple[Array, Array] # noqa: UP006
y: Tuple[Array, Array] # ruff:ignore[non-pep585-annotation]

with pytest.raises(TypeError, match=r"Field 'y':.*has an element type.*"):
dataclass_array_container(ArrayContainerWithTuple)
Expand Down
9 changes: 7 additions & 2 deletions test/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

import numpy as np

from pytools.obj_array import ObjectArray1D # noqa: TC001
from pytools.obj_array import (
ObjectArray1D, # ruff:ignore[typing-only-first-party-import]
)

from arraycontext import (
ArrayContext,
Expand All @@ -37,7 +39,10 @@
with_array_context,
with_container_arithmetic,
)
from arraycontext.typing import ArrayOrContainer, ScalarLike # noqa: TC001
from arraycontext.typing import ( # ruff:ignore[typing-only-first-party-import]
ArrayOrContainer,
ScalarLike,
)


# Containers live here, because in order for get_annotations to work, they must
Expand Down
Loading