astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
30.73k stars 1.02k forks source link

Implement more flake8-bugbear opinionated rules #3758

Open sjdemartini opened 1 year ago

sjdemartini commented 1 year ago

Picking up where https://github.com/charliermarsh/ruff/issues/2954 left off, there were a few opinionated (B9xx flake8-bugbear rules) checks left to be implemented in Ruff:

There's an open question on how these should be included, since it would deviate from flake8-bugbear to have these on by default just by turning on the rest of the bugbear rules (see comment https://github.com/charliermarsh/ruff/issues/2954#issuecomment-1483594606).

There's also one outstanding non-opinionated rule:

Pierre-Sassoulas commented 1 year ago

B906 is flake8 plugins specific and has a false positive when the visit function is visiting an astroid node in a pylint plugin. It would be nice to not have this FP in ruff :)

mikaelarguedas commented 8 months ago

Since then some new rule apppeared

charliermarsh commented 8 months ago

Good first issues for anyone interested :)

mikaelarguedas commented 7 months ago

Another 2 rules appeared in flake8-bugbear:

Skylion007 commented 7 months ago

B037 is already implemented as PLE0100, @charliermarsh maybe we should consider migrating PLE0100 to B037 though?

charliermarsh commented 7 months ago

@Skylion007 - Yes good call -- I prefer indexing under bugbear over Pylint since it's more popular for Ruff users. I'll add a note to the 0.2.0 release list.

mikaelarguedas commented 7 months ago

@zanieb Was this closed on purpose ?

I'm under the impression that some rules listed here are not part of ruff yet: B036, B038, B901, B902, B903, B907, B908

charliermarsh commented 7 months ago

@mikaelarguedas - I think it was an oversight, but I'll leave it to @zanieb to confirm in the AM.

mscheifer commented 4 months ago

I think B036 is covered/aliased by BLE001.

mikaelarguedas commented 4 months ago

@charliermarsh @zanieb friendly :bellhop_bell: if it was closed by mistake, is it possible to reopen and update according to current state ?

Current state: B036 -> covered by BLE001 B038 -> no implemented B901 -> no implemented B902 ->no implemented B903 ->no implemented B907 ->no implemented B908 ->no implemented

charliermarsh commented 4 months ago

Will update the list, thanks.

charliermarsh commented 4 months ago

Updated. We do actually have B038 (which bugbear moved to B909).

jnrbsn commented 2 weeks ago

This issue says that B902 is "Implemented as N804 and N805", but that is not accurate because N804 incorrectly says you should use cls for "metaclass class methods" (e.g. __new__, __prepare__). These methods are the metaclass-equivalent of class methods and get passed the metaclass itself as the first argument. flake8-bugbear recommends metacls, and pylint recommends mcs (which flake8-bugbear will also accept).