-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
good first issueGood for newcomersGood for newcomerspluginImplementing a known but unsupported pluginImplementing a known but unsupported plugin
Description
Looks like bugbear has new rules:
- B028: No explicit stacklevel keyword argument found. The warn method from the warnings module uses a stacklevel of 1 by default. This will only show a stack trace for the line on which the warn method is called. It is therefore recommended to use a stacklevel of 2 or greater to provide more information to the user.
- B029: Using except (): with an empty tuple does not handle/catch anything. Add exceptions to handle.
- B030: Except handlers should only be exception classes or tuples of exception classes.
- B031: Using the generator returned from itertools.groupby() more than once will do nothing on the second usage. Save the result to a list if the result is needed multiple times.
- B032: Possible unintentional type annotation (using :). Did you mean to assign (using =)?
Also, some of the B9 rules are nice if opted into explicitly and seem to be missing (B90x except B901 (Python 2 related) & B907 which is nice but poorly implemented in bugbear) - only B904 is present.
I don't actually need these for something specific, just noticed this due to an incorrect noqa and thought a tracking issue would be useful.
Opinionated checks:
- B901: Using
return xin a generator function. (Somewhat bad reasoning in description, talks about Python 2, see comments below.) - B902: Invalid first argument used for method.
- B903: Use collections.namedtuple (or typing.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's
dataclassesnowadays.) - B906:
visit_function with no further call to avisitfunction.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomerspluginImplementing a known but unsupported pluginImplementing a known but unsupported plugin