Skip to content

Implement C403#335

Merged
charliermarsh merged 1 commit into
astral-sh:mainfrom
harupy:C403
Oct 6, 2022
Merged

Implement C403#335
charliermarsh merged 1 commit into
astral-sh:mainfrom
harupy:C403

Conversation

@harupy
Copy link
Copy Markdown
Contributor

@harupy harupy commented Oct 6, 2022

#305

> cargo run -- --select=C403 resources/test/fixtures/C403.py
resources/test/fixtures/C403.py:1:5: C403 Unnecessary list comprehension - rewrite as a set comprehension

@harupy
Copy link
Copy Markdown
Contributor Author

harupy commented Oct 6, 2022

It looks like this check is auto-fixable. I will file a follow-up PR (if this is really auto-fixable).

@charliermarsh
Copy link
Copy Markdown
Member

This looks great, thanks.

Comment thread src/check_ast.rs
if self.settings.enabled.contains(&CheckCode::C403) {
if let Some(check) = checks::unnecessary_list_comprehension(expr, func, args) {
self.checks.push(check);
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm trying to establish a pattern whereby we add new checks to plugins, and every plugin takes &mut self as its first argument. But that might be overkill for these really simple cases. (Better when there's a lot of logic around the checks:: call.)

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