Skip to content

Several ruff:ignore fixes#26412

Draft
ntBre wants to merge 6 commits into
mainfrom
brent/add-ignore-fixes
Draft

Several ruff:ignore fixes#26412
ntBre wants to merge 6 commits into
mainfrom
brent/add-ignore-fixes

Conversation

@ntBre

@ntBre ntBre commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

This is currently stacked on #26346 and fixes the differences I noted between --add-noqa and --add-ignore when running on our ecosystem projects.

Test Plan

New tests derived from the ecosystem check

ntBre added 6 commits June 26, 2026 09:36
Summary
--

This PR adds the `--add-ignore` flag as an alias to `--add-noqa`. In preview, this adds
`ruff:ignore` comments with human-readable names instead of `noqa` comments with codes.

I initially drafted this PR assuming that `--add-ignore` would be a separate flag that only
functioned in preview mode, while `--add-noqa` would be available in both preview and stable, but
after talking with Micha realized that we probably want to go ahead and push preview users toward
`--add-ignore` entirely rather than giving them the choice. I think the one downside of the alias
approach is that `--add-noqa` still exists in preview but will still add `ruff:ignore` comments.

In cases where an existing `noqa` or `ruff:ignore` comment is present, I opted to preserve the
existing comment and to append the new comment. So something like this:

```py
import math  # noqa: RUF100
```

becomes:

```py
import math  # noqa: RUF100 # ruff:ignore[unused-import]
```

instead of also converting the existing `noqa` comment. I think we can defer to one of our planned
lint rules for the conversion (and joining) instead.

As also shown in this example, the flag adds human-readable names rather than rule codes and prefers
the same placement as a `noqa` comment, at the end of the line. The one exception to this is an
existing `ruff:ignore` comment on its own line. In that case, we will reuse and extend the existing
comment instead of adding an additional trailing comment, which I think is a pretty nice balance.

Test Plan
--

Many new CLI tests exercising the various cases Codex and I could come up with. As the server test
shows, this actually applies to the LSP as well, where the `Disable for this line` action now also
inserts a `ruff:ignore` comment with a rule name instead of a `noqa` comment.
@astral-sh-bot

astral-sh-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+79 -1 violations, +0 -0 fixes in 3 projects; 53 projects unchanged)

apache/superset (+5 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --no-preview --select ALL

+ superset/db_engine_specs/kusto.py:103:89: E501 Line too long (89 > 88)
+ superset/db_engine_specs/kusto.py:103:92: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ tests/integration_tests/superset_test_config_thumbnails.py:39:22: RUF100 [*] Unused `noqa` directive (unused: `F405`)
+ tests/integration_tests/superset_test_config_thumbnails.py:39:5: F405 `logger` may be undefined, or defined from star imports
+ tests/integration_tests/superset_test_config_thumbnails.py:48:5: ANN201 Missing return type annotation for public function `GET_FEATURE_FLAGS_FUNC`
- tests/integration_tests/superset_test_config_thumbnails.py:48:5: ANN201 Missing return type annotation for public function `GET_FEATURE_FLAGS_FUNC`

langchain-ai/langchain (+5 -0 violations, +0 -0 fixes)

+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:18:40: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:27:36: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:36:41: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:45:52: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:54:40: RUF100 [*] Unused `noqa` directive (unused: `E501`)

rotki/rotki (+69 -0 violations, +0 -0 fixes)

+ rotkehlchen/data_migrations/migrations/migrations_18.py:70:100: E501 Line too long (114 > 99)
+ rotkehlchen/data_migrations/migrations/migrations_18.py:70:103: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/l2withl1feestx.py:45:100: E501 Line too long (104 > 99)
+ rotkehlchen/db/l2withl1feestx.py:45:107: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v28_v29.py:22:13: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v28_v29.py:41:13: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v30_v31.py:100:100: E501 Line too long (170 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:104:100: E501 Line too long (170 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:108:100: E501 Line too long (170 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:112:100: E501 Line too long (170 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:142:100: E501 Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:144:100: E501 Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:146:100: E501 Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:148:100: E501 Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:150:100: E501 Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:152:100: E501 Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:154:100: E501 Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:156:100: E501 Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:174:8: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v30_v31.py:75:100: E501 Line too long (113 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:76:53: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v30_v31.py:95:100: E501 Line too long (110 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:97:100: E501 Line too long (110 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:127:100: E501 Line too long (114 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:129:13: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v31_v32.py:135:100: E501 Line too long (111 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:136:100: E501 Line too long (107 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:138:13: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v31_v32.py:144:100: E501 Line too long (107 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:146:13: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v31_v32.py:151:100: E501 Line too long (113 > 99)
... 18 additional changes omitted for rule E501
+ rotkehlchen/db/upgrades/v31_v32.py:153:13: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v31_v32.py:90:104: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v32_v33.py:447:103: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v36_v37.py:112:15: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v41_v42.py:133:17: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v47_v48.py:377:108: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v50_v51.py:115:15: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:442:15: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:453:15: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:461:15: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:478:15: RUF100 [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:490:15: RUF100 [*] Unused `noqa` directive (unused: `E501`)
... 26 additional changes omitted for project

Changes by rule (4 rules affected)

code total + violation - violation + fix - fix
E501 40 40 0 0 0
RUF100 37 37 0 0 0
ANN201 2 1 1 0 0
F405 1 1 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+78 -0 violations, +0 -0 fixes in 3 projects; 53 projects unchanged)

apache/superset (+4 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --preview --select ALL

+ superset/db_engine_specs/kusto.py:103:89: line-too-long Line too long (89 > 88)
+ superset/db_engine_specs/kusto.py:103:92: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ tests/integration_tests/superset_test_config_thumbnails.py:39:22: unused-noqa [*] Unused `noqa` directive (unused: `F405`)
+ tests/integration_tests/superset_test_config_thumbnails.py:39:5: undefined-local-with-import-star-usage `logger` may be undefined, or defined from star imports

langchain-ai/langchain (+5 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --preview

+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:18:40: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:27:36: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:36:41: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:45:52: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ libs/langchain/langchain_classic/agents/react/wiki_prompt.py:54:40: unused-noqa [*] Unused `noqa` directive (unused: `E501`)

rotki/rotki (+69 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --preview

+ rotkehlchen/data_migrations/migrations/migrations_18.py:70:100: line-too-long Line too long (100 > 99)
+ rotkehlchen/data_migrations/migrations/migrations_18.py:70:103: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/l2withl1feestx.py:45:100: line-too-long Line too long (104 > 99)
+ rotkehlchen/db/l2withl1feestx.py:45:107: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v28_v29.py:22:13: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v28_v29.py:41:13: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v30_v31.py:100:100: line-too-long Line too long (170 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:104:100: line-too-long Line too long (170 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:108:100: line-too-long Line too long (170 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:112:100: line-too-long Line too long (170 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:142:100: line-too-long Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:144:100: line-too-long Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:146:100: line-too-long Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:148:100: line-too-long Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:150:100: line-too-long Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:152:100: line-too-long Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:154:100: line-too-long Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:156:100: line-too-long Line too long (129 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:174:8: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v30_v31.py:75:100: line-too-long Line too long (113 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:76:53: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v30_v31.py:95:100: line-too-long Line too long (110 > 99)
+ rotkehlchen/db/upgrades/v30_v31.py:97:100: line-too-long Line too long (110 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:127:100: line-too-long Line too long (114 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:129:13: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v31_v32.py:135:100: line-too-long Line too long (111 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:136:100: line-too-long Line too long (107 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:138:13: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v31_v32.py:144:100: line-too-long Line too long (107 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:146:13: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v31_v32.py:151:100: line-too-long Line too long (113 > 99)
+ rotkehlchen/db/upgrades/v31_v32.py:153:13: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v31_v32.py:90:100: line-too-long Line too long (101 > 99)
... 17 additional changes omitted for rule line-too-long
+ rotkehlchen/db/upgrades/v31_v32.py:90:104: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v32_v33.py:447:103: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v36_v37.py:112:15: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v41_v42.py:133:17: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v47_v48.py:377:108: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/db/upgrades/v50_v51.py:115:15: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:442:15: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:453:15: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:461:15: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:478:15: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:490:15: unused-noqa [*] Unused `noqa` directive (unused: `E501`)
... 25 additional changes omitted for project

Changes by rule (3 rules affected)

code total + violation - violation + fix - fix
line-too-long 40 40 0 0 0
unused-noqa 37 37 0 0 0
undefined-local-with-import-star-usage 1 1 0 0 0

@ntBre ntBre force-pushed the brent/add-ignore branch from ac10c98 to b141602 Compare June 26, 2026 17:49
ntBre added a commit that referenced this pull request Jul 7, 2026
Summary
--

This PR adds the new `--add-ignore` flag. In preview, this adds
`ruff:ignore` comments with human-readable names instead of `noqa`
comments with codes. Without preview enabled, using the flag emits an
error. `--add-noqa` itself is still available in both preview and stable
mode.

In cases where an existing `noqa` or `ruff:ignore` comment is present, I
opted to preserve the
existing comment and to append the new comment. So something like this:

```py
import math  # noqa: RUF100
```

becomes:

```py
import math  # noqa: RUF100 # ruff:ignore[unused-import]
```

instead of also converting the existing `noqa` comment. I think we can
defer to one of our planned
lint rules for the conversion (and joining) instead.

As also shown in this example, the flag adds human-readable names rather
than rule codes and prefers
the same placement as a `noqa` comment, at the end of the line. The one
exception to this is an
existing `ruff:ignore` comment on its own line. In that case, we will
reuse and extend the existing
comment instead of adding an additional trailing comment, which I think
is a pretty nice balance.

Test Plan
--

Many new tests exercising the various cases Codex and I could come up
with. As the server test
shows, this actually applies to the LSP as well, where the `Disable for
this line` action now also
inserts a `ruff:ignore` comment with a rule name instead of a `noqa`
comment.

Ecosystem check
--

I also ran some tests against ecosystem projects as described in my
[comment](#26346 (comment))
below. These revealed some additional discrepancies between
`ruff:ignore` and `noqa` (and some bugs in `noqa`/`--add-noqa` itself),
but I think it makes sense to leave these as follow-ups. I've already
opened (rough) drafts of them in:
- #26373
- #26409
- #26412

We could land the shebang fixes separately, but the other two are
stacked on this PR. With all three of these applied, the ecosystem check
showed parity with `--add-noqa`.

This also seems like an interesting check to add to our ecosystem
analysis in general.
Base automatically changed from brent/add-ignore to main July 7, 2026 16:26
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.

1 participant