-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Picking up where #2954 left off, there were a few opinionated (B9xx flake8-bugbear rules) checks left to be implemented in Ruff:
- B901: Using
return xin a generator function. (Somewhat bad reasoning in flake8-bugbear description, talks about Python 2, see comment here Update bugbear #2954 (comment) around its utility.)
- B902: Implemented as N804 and N805.
- B903: Use
collections.namedtuple(ortyping.NamedTuple) for data classes that only set attributes in an__init__method, and do nothing else. (Probably should include dataclasses recommendation? NamedTuple injects extra tuple methods and is meant for backward compat, not a data class replacement. That'sdataclassesnowadays.) -
B906:visit_function with no further call to avisitfunction.
- B907: Consider replacing f"'{foo}'" with f"{foo!r}" which is both easier to read and will escape quotes inside foo if that would appear.
- B908: Partly implemented as PT012.
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 #2954 (comment)).
There's also one outstanding non-opinionated rule:
- B036: Found except BaseException: without re-raising (no raise in the top-level of the except block). This catches all kinds of things (Exception, SystemExit, KeyboardInterrupt...) and may prevent a program from exiting as expected. Implemented as BLE001.
- B038: Renamed to B909 in bugbear; implemented as B909 is Ruff.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule