Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid F401 panic with noqa import name #7260

Merged
merged 1 commit into from
Sep 10, 2023
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
8 changes: 8 additions & 0 deletions crates/ruff/resources/test/fixtures/pyflakes/F401_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,11 @@ def b(self) -> None:
import b1

import b2


# Regression test for: https://github.com/astral-sh/ruff/issues/7244
from datameta_client_lib.model_utils import ( # noqa: F401
noqa )

from datameta_client_lib.model_helpers import (
noqa )
2 changes: 1 addition & 1 deletion crates/ruff/src/noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a> Directive<'a> {
if text[..comment_start]
.chars()
.last()
.is_some_and(|c| c != '#')
.map_or(true, |c| c != '#')
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ F401_0.py:112:16: F401 [*] `b1` imported but unused
112 |- import b1
113 112 |
114 113 | import b2
115 114 |

F401_0.py:114:16: F401 [*] `b2` imported but unused
|
Expand All @@ -263,5 +264,23 @@ F401_0.py:114:16: F401 [*] `b2` imported but unused
112 112 | import b1
113 113 |
114 |- import b2
115 114 |
116 115 |
117 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7244

F401_0.py:122:1: F401 [*] `datameta_client_lib.model_helpers.noqa` imported but unused
|
121 | from datameta_client_lib.model_helpers import (
122 | noqa )
| ^^^^ F401
|
= help: Remove unused import: `datameta_client_lib.model_helpers.noqa`

ℹ Fix
118 118 | from datameta_client_lib.model_utils import ( # noqa: F401
119 119 | noqa )
120 120 |
121 |-from datameta_client_lib.model_helpers import (
122 |-noqa )


Loading