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

Reject more syntactically invalid Python programs #8524

Merged
merged 3 commits into from
Nov 7, 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: 6 additions & 2 deletions crates/ruff_linter/src/rules/eradicate/detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,15 @@ mod tests {
"# ( user_content_type , _ )= TimelineEvent.objects.using(db_alias).get_or_create(",
&[]
));
assert!(comment_contains_code(
assert!(comment_contains_code("# )", &[]));

// This used to return true, but our parser has gotten a bit better
// at rejecting invalid Python syntax. And indeed, this is not valid
// Python code.
assert!(!comment_contains_code(
"# app_label=\"core\", model=\"user\"",
&[]
));
assert!(comment_contains_code("# )", &[]));

// TODO(charlie): This should be `true` under aggressive mode.
assert!(!comment_contains_code("#def foo():", &[]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ def foo():
pass


(yield a, b) = (1, 2)

# some comment
for e in l : yield e # some comment

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ def foo():
pass


(yield a, b) = (1, 2)

# some comment
for e in l : yield e # some comment

Expand Down Expand Up @@ -151,8 +149,6 @@ def foo():
# comment
pass

(yield a, b) = (1, 2)

# some comment
for e in l:
yield e # some comment
Expand Down
Loading
Loading