Skip to content

MAINT: Enforce additional ruff rules#416

Open
DimitriPapadopoulos wants to merge 7 commits intodata-apis:mainfrom
DimitriPapadopoulos:ruff
Open

MAINT: Enforce additional ruff rules#416
DimitriPapadopoulos wants to merge 7 commits intodata-apis:mainfrom
DimitriPapadopoulos:ruff

Conversation

@DimitriPapadopoulos
Copy link
Copy Markdown

No description provided.

Loop control variable not used within loop body
Do not call `getattr` with a constant attribute value.
It is not any safer than normal property access.
Unnecessary generator (rewrite as a set comprehension)
Unnecessary `list()` call within `sorted()`
PEP 484 prohibits implicit `Optional`
Unused `noqa` directive
Copilot AI review requested due to automatic review settings April 5, 2026 16:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This maintenance PR tightens linting by enabling additional Ruff rule sets and updates code/tests to comply with the newly enforced checks.

Changes:

  • Expanded Ruff select to include additional rule families (e.g., B, PERF, UP, FURB) and enabled RUF100 to detect unused noqa directives.
  • Adjusted tests and library code to satisfy new lint expectations (avoid constant-string getattr, simplify set/list constructions, improve type annotations).
  • Reduced/removed some noqa usage where it’s no longer needed.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyproject.toml Enables additional Ruff lint rules and adds targeted ignores.
tests/test_no_dependencies.py Removes constant-string getattr calls to satisfy new lint rules.
tests/test_isdtype.py Removes an inline noqa, but currently introduces a Ruff E721 lint failure.
array_api_compat/torch/fft.py Improves optional type annotations for FFT wrappers; RUF100 may expose an unused noqa in the file.
array_api_compat/torch/_aliases.py Replaces unused loop variable with _.
array_api_compat/numpy/__init__.py Removes a file-level noqa directive now that it’s not needed.
array_api_compat/cupy/linalg.py Simplifies __all__ de-duplication construction.
array_api_compat/common/_helpers.py Uses set comprehension for clarity and lint compliance.
array_api_compat/__init__.py Removes an unnecessary noqa code from the star import.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants