Skip to content

Ruff

903 rules ruff@0.17.0

Complete effective rule inventory.

Docs

Rules

32 rules on this page · 903 total

  • B017

    Do not assert blind exception: {exception}

    No autofix
  • B018

    Found useless expression. Either assign it to a variable or remove it.

    No autofix
  • B019

    Use of functools.lru_cache or functools.cache on methods can lead to memory leaks

    No autofix
  • B020

    Loop control variable {name} overrides iterable it iterates

    No autofix
  • B021

    f-string used as docstring. Python will interpret this as a joined string, rather than a docstring.

    No autofix
  • B022

    No arguments passed to contextlib.suppress. No exceptions will be suppressed and therefore this context manager is redundant

    No autofix
  • B023

    Function definition does not bind loop variable {name}

    No autofix
  • B024

    {name} is an abstract base class, but it has no abstract methods or properties

    No autofix
  • B025

    try-except* block with duplicate exception {name}

    No autofix
  • B026

    Star-arg unpacking after a keyword argument is strongly discouraged

    No autofix
  • B027

    {name} is an empty method in an abstract base class, but has no abstract decorator

    No autofix
  • B028

    No explicit stacklevel keyword argument found

    Always autofixable
  • B029

    Using except* (): with an empty tuple does not catch anything; add exceptions to handle

    No autofix
  • B030

    except* handlers should only be exception classes or tuples of exception classes

    No autofix
  • B031

    Using the generator returned from itertools.groupby() more than once will do nothing on the second usage

    No autofix
  • B032

    Possible unintentional type annotation (using :). Did you mean to assign (using =)?

    No autofix
  • B033

    Sets should not contain duplicate item {value}

    Some reports are autofixable
  • B034

    {method} should pass {param_name} and flags as keyword arguments to avoid confusion due to unintuitive argument positions

    No autofix
  • B035

    Dictionary comprehension uses static key: {key}

    No autofix
  • B039

    Do not use mutable data structures for ContextVar defaults

    No autofix
  • B043

    Do not call delattr with a constant attribute value. It is not any safer than normal property deletion.

    Always autofixable
  • B901

    Using yield and return {value} in a generator function can lead to confusing behavior

    No autofix
  • B903

    Class could be dataclass or namedtuple

    No autofix
  • B904

    Within an except* clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

    No autofix
  • B905

    zip() without an explicit strict= parameter

    Always autofixable
  • B909

    Mutation to loop iterable {name} during iteration

    No autofix
  • B911

    itertools.batched() without an explicit strict parameter

    No autofix
  • B912

    map() without an explicit strict= parameter

    Always autofixable
  • BLE001

    Do not catch blind exception: {name}

    No autofix
  • C400

    Unnecessary generator (rewrite using list())

    Always autofixable
  • C401

    Unnecessary generator (rewrite using set())

    Always autofixable
  • C402

    Unnecessary generator (rewrite as a dict comprehension)

    Always autofixable