diff --git a/arraycontext/container/arithmetic.py b/arraycontext/container/arithmetic.py index b3c60d49..50d48a11 100644 --- a/arraycontext/container/arithmetic.py +++ b/arraycontext/container/arithmetic.py @@ -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 ( @@ -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"", "exec"), # noqa: S102 + exec(compile(code, f"", "exec"), # ruff:ignore[exec-builtin] result_dict) return cls diff --git a/arraycontext/container/dataclass.py b/arraycontext/container/dataclass.py index 0fff68b2..75630110 100644 --- a/arraycontext/container/dataclass.py +++ b/arraycontext/container/dataclass.py @@ -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"", # noqa: S102 + exec(compile(serialize_code, f"", # ruff:ignore[exec-builtin] "exec"), exec_dict) return cls diff --git a/arraycontext/container/traversal.py b/arraycontext/container/traversal.py index c2c05bf5..e84595ff 100644 --- a/arraycontext/container/traversal.py +++ b/arraycontext/container/traversal.py @@ -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:] @@ -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 ( diff --git a/arraycontext/impl/pytato/__init__.py b/arraycontext/impl/pytato/__init__.py index a8ec6def..4d385ff9 100644 --- a/arraycontext/impl/pytato/__init__.py +++ b/arraycontext/impl/pytato/__init__.py @@ -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 @@ -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 @@ -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 diff --git a/arraycontext/impl/pytato/compile.py b/arraycontext/impl/pytato/compile.py index 79a7004a..b16baa64 100644 --- a/arraycontext/impl/pytato/compile.py +++ b/arraycontext/impl/pytato/compile.py @@ -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) diff --git a/arraycontext/impl/pytato/outline.py b/arraycontext/impl/pytato/outline.py index 547d48f0..a2d627f1 100644 --- a/arraycontext/impl/pytato/outline.py +++ b/arraycontext/impl/pytato/outline.py @@ -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 diff --git a/arraycontext/pytest.py b/arraycontext/pytest.py index 1a160ad4..dda02047 100644 --- a/arraycontext/pytest.py +++ b/arraycontext/pytest.py @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/arraycontext/typing.py b/arraycontext/typing.py index 043ef4d8..70758fe0 100644 --- a/arraycontext/typing.py +++ b/arraycontext/typing.py @@ -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: ... diff --git a/doc/conf.py b/doc/conf.py index 354ad41a..3d32dd9b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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] diff --git a/examples/stub.py b/examples/stub.py index 205e31dd..71733075 100644 --- a/examples/stub.py +++ b/examples/stub.py @@ -1 +1 @@ -import arraycontext # noqa +import arraycontext # ruff:ignore[unused-import, missing-required-import] diff --git a/pyproject.toml b/pyproject.toml index 48910422..10502e49 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] @@ -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 = [ diff --git a/test/test_arraycontext.py b/test/test_arraycontext.py index e5336cc2..30eb8a88 100644 --- a/test/test_arraycontext.py +++ b/test/test_arraycontext.py @@ -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: diff --git a/test/test_utils.py b/test/test_utils.py index f58432f1..4d71e391 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -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] @@ -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`) @@ -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) diff --git a/test/testlib.py b/test/testlib.py index 25aa18c0..4a7971d8 100644 --- a/test/testlib.py +++ b/test/testlib.py @@ -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, @@ -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