Skip to content

Ruff

902 rules ruff@0.16.8

Complete effective rule inventory.

Docs

Rules

40 rules on this page · 902 total

  • E711

    Comparison to None should be cond is None

    Always autofixable
  • E712

    Avoid equality comparisons to True; use {cond}: for truth checks

    Always autofixable
  • E713

    Test for membership should be not in

    Always autofixable
  • E714

    Test for object identity should be is not

    Always autofixable
  • E721

    Use is and is not for type comparisons, or isinstance() for isinstance checks

    No autofix
  • E722

    Do not use bare except

    No autofix
  • E731

    Do not assign a lambda expression, use a def

    Some reports are autofixable
  • E741

    Ambiguous variable name: {name}

    No autofix
  • E742

    Ambiguous class name: {name}

    No autofix
  • E743

    Ambiguous function name: {name}

    No autofix
  • E902

    {message}

    No autofix
  • EM101

    Exception must not use a string literal, assign to variable first

    Some reports are autofixable
  • EM102

    Exception must not use an f-string literal, assign to variable first

    Some reports are autofixable
  • EM103

    Exception must not use a .format() string directly, assign to variable first

    Some reports are autofixable
  • EXE001

    Shebang is present but file is not executable

    No autofix
  • EXE002

    The file is executable but no shebang is present

    No autofix
  • EXE003

    Shebang should contain python, pytest, or uv run

    No autofix
  • EXE004

    Avoid whitespace before shebang

    Always autofixable
  • EXE005

    Shebang should be at the beginning of the file

    No autofix
  • F401

    {name} imported but unused; consider using importlib.util.find_spec to test for availability

    Some reports are autofixable
  • F402

    Import {name} from {row} shadowed by loop variable

    No autofix
  • F403

    from {name} import * used; unable to detect undefined names

    No autofix
  • F404

    from __future__ imports must occur at the beginning of the file

    No autofix
  • F405

    {name} may be undefined, or defined from star imports

    No autofix
  • F406

    from {name} import * only allowed at module level

    No autofix
  • F407

    Future feature {name} is not defined

    No autofix
  • F501

    %-format string has invalid format string: {message}

    No autofix
  • F502

    %-format string expected mapping but got sequence

    No autofix
  • F503

    %-format string expected sequence but got mapping

    No autofix
  • F504

    %-format string has unused named argument(s): {message}

    Always autofixable
  • F505

    %-format string is missing argument(s) for placeholder(s): {message}

    No autofix
  • F506

    %-format string has mixed positional and named placeholders

    No autofix
  • F507

    %-format string has {wanted} placeholder(s) but {got} substitution(s)

    No autofix
  • F508

    %-format string * specifier requires sequence

    No autofix
  • F509

    %-format string has unsupported format character {char}

    No autofix
  • F521

    .format call has invalid format string: {message}

    No autofix
  • F522

    .format call has unused named argument(s): {message}

    Some reports are autofixable
  • F523

    .format call has unused arguments at position(s): {message}

    Some reports are autofixable
  • F524

    .format call is missing argument(s) for placeholder(s): {message}

    No autofix
  • F525

    .format string mixes automatic and manual numbering

    No autofix