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

Implement flake8-walrus #3464

Open
1 task
Cielquan opened this issue Mar 12, 2023 · 7 comments
Open
1 task

Implement flake8-walrus #3464

Cielquan opened this issue Mar 12, 2023 · 7 comments
Labels
needs-decision Awaiting a decision from a maintainer plugin Implementing a known but unsupported plugin

Comments

@Cielquan
Copy link

flake8-walrus

Forbids usage of the := walrus operator.

Error Codes

  • ASN001 do not use assignment expressions
@charliermarsh charliermarsh added the plugin Implementing a known but unsupported plugin label Mar 12, 2023
@kyoto7250
Copy link
Contributor

Personally, I would like to work on implementing this plugin, but is this an appropriate rule to incorporate into ruff?

I know there were objections to the introduction of this operator, but I feel this rule is a matter of user preference.

@MichaReiser
Copy link
Member

What's the rational of forbidding the operator (other than lol :D). Is it useful to a broad audience of the Python community?

@Cielquan
Copy link
Author

Cielquan commented Apr 6, 2023

The objection is readability. It may not be the only one, but it is mine.
I totally see that it is somewhat of a nice QoL feature, but I and others too do not want to exchange readability for 1 line of code saved.

And I do not want others to be able to use it in code I maintain, so I forbid its usage via the flake8 plugin by running flake8 in CI.

It is totally subjective preference but so is any style rule somehow, is it not?
But in comparison to PEP8 it is rather niche I guess. So I can see why one would not want to implement it. But nontheless I and probably others too would like to have it being implemented. 😉

@charliermarsh
Copy link
Member

Yeah, I think this is a hard one for us to merge until we have a clearer policy on opinionated rules / plugins (similar to #3463).

@MichaReiser
Copy link
Member

MichaReiser commented Apr 11, 2023

It is totally subjective preference but so is any style rule somehow, is it not?
But in comparison to PEP8 it is rather niche I guess. So I can see why one would not want to implement it. But nontheless I and probably others too would like to have it being implemented.

Thanks for explaining your motivation.

We're considering reorganizing the ruff rules and one category that we intend to introduce is restriction. Rules in the restriction category are opinionated, not recommended for most users, and restrict the allowed language feature. I could see this rule fit into that category if it satisfies the criteria that it is useful to some community users (we don't want to have "I don't like" rules, where I is a single person).

@Cielquan
Copy link
Author

The restriction category sounds very nice. I think this will be a very good way to separate those special rules.

Sure, when e.g. I am the only one using it, I would have to wait for plugin support and write my own plugin for this. This makes sense to me.

@charliermarsh charliermarsh added the needs-decision Awaiting a decision from a maintainer label Jul 10, 2023
@MichaReiser
Copy link
Member

#13741 is related where the author asked for restricting most, but not all walrus operators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer plugin Implementing a known but unsupported plugin
Projects
None yet
Development

No branches or pull requests

4 participants