Skip to content

Ruff

902 rules ruff@0.16.8

Complete effective rule inventory.

Docs

Rules

40 rules on this page · 902 total

  • ASYNC210

    Async functions should not call blocking HTTP methods

    No autofix
  • ASYNC212

    Blocking httpx method {name}.{call}() in async context, use httpx.AsyncClient

    No autofix
  • ASYNC220

    Async functions should not create subprocesses with blocking methods

    No autofix
  • ASYNC221

    Async functions should not run processes with blocking methods

    No autofix
  • ASYNC222

    Async functions should not wait on processes with blocking methods

    No autofix
  • ASYNC230

    Async functions should not open files with blocking methods like open

    No autofix
  • ASYNC240

    Async functions should not perform blocking {path_library} operations

    No autofix
  • ASYNC250

    Blocking call to input() in async context

    No autofix
  • ASYNC251

    Async functions should not call time.sleep

    No autofix
  • B002

    Python does not support the unary prefix increment operator (++)

    No autofix
  • B003

    Assigning to os.environ doesn't clear the environment

    No autofix
  • B004

    Using hasattr(x, "__call__") to test if x is callable is unreliable. Use callable(x) for consistent results.

    Some reports are autofixable
  • B005

    Using .strip() with multi-character strings is misleading

    No autofix
  • B006

    Do not use mutable data structures for argument defaults

    Some reports are autofixable
  • B007

    Loop control variable {name} not used within loop body

    Some reports are autofixable
  • B008

    Do not perform function call {name} in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

    No autofix
  • B009

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

    Always autofixable
  • B010

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

    Always autofixable
  • B011

    Do not assert False (python -O removes these calls), raise AssertionError()

    Always autofixable
  • B012

    {name} inside finally blocks cause exceptions to be silenced

    No autofix
  • B013

    A length-one tuple literal is redundant in exception handlers

    Always autofixable
  • B014

    Exception handler with duplicate exception: {name}

    Always autofixable
  • B015

    Pointless comparison. Did you mean to assign a value? Otherwise, prepend assert or remove it.

    No autofix
  • B016

    Cannot raise a literal. Did you intend to return it or raise an Exception?

    No autofix
  • 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