Skip to content

B024: ruff in pre-commit fails to recognise B024 with the presence of a class variable #14455

@cmp0xff

Description

@cmp0xff

List of keywords I searched for before creating this issue

  • B024

A minimal code snippet that reproduces the bug

from abc import ABC


class Foo(ABC):
    a: int
    def method(self) -> None:
        print("nothing")

The command you invoked

poetry run pre-commit run -a

The current Ruff settings

Relevant snippet of .pre-commit-config.yaml

  - repo: https://github.com/astral-sh/ruff/
    rev: 0.7.4
    hooks:
      # Run the linter.
      - id: ruff
        args:
          - --fix
          - --exit-non-zero-on-fix

Relevant snippet of pyproject.py

[tool.ruff]
line-length = 88
force-exclude = true # Recommended for pre-commit (https://github.com/charliermarsh/ruff#force-exclude)
# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "venv",
]
target-version = "py310"
# unsafe-fixes = true

[tool.ruff.lint.per-file-ignores]
"*ipynb*" = [
  "B018",  # https://docs.astral.sh/ruff/rules/useless-expression/
]

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
select = ["ALL"]
ignore = [
  "ANN001",  # https://docs.astral.sh/ruff/rules/missing-type-function-argument/
  "ANN201",  # https://docs.astral.sh/ruff/rules/missing-return-type-undocumented-public-function/
  "ANN202",  # https://docs.astral.sh/ruff/rules/missing-return-type-private-function/
  "ANN401",  # https://docs.astral.sh/ruff/rules/any-type/
  "ARG",     # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
  "B007",    # https://docs.astral.sh/ruff/rules/unused-loop-control-variable/
  "B023",    # https://docs.astral.sh/ruff/rules/function-uses-loop-variable/
  "B905",    # https://docs.astral.sh/ruff/rules/zip-without-explicit-strict/
  "C408",    # https://docs.astral.sh/ruff/rules/unnecessary-collection-call/
  "C901",    # https://docs.astral.sh/ruff/rules/complex-structure/
  "D",       # https://docs.astral.sh/ruff/rules/#pydocstyle-d
  "DTZ001",  # https://docs.astral.sh/ruff/rules/call-datetime-without-tzinfo/
  "E501",    # https://docs.astral.sh/ruff/rules/line-too-long/ (handled by black)
  "E722",    # https://docs.astral.sh/ruff/rules/bare-except/
  "E731",    # https://docs.astral.sh/ruff/rules/lambda-assignment/
  "F841",    # https://docs.astral.sh/ruff/rules/unused-variable/
  "G",       # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
  "S101",    # https://docs.astral.sh/ruff/rules/assert/
  "S301",    # https://docs.astral.sh/ruff/rules/suspicious-pickle-usage/
  "S608",    # https://docs.astral.sh/ruff/rules/hardcoded-sql-expression/
  "SIM114",  # https://docs.astral.sh/ruff/rules/if-with-same-arms/
  "BLE", "COM", "EM", "ERA", "FIX", "FBT", "FLY", "INP",
  "N",
  "PD",
  "PERF", "PGH",
  "PLC", "PLR", "PLW",
  "PT",
  "PTH",
  "PYI", "RET",
  "SLF",
  "T201",
  "TCH", "TD", "TID", "TRY", "UP", "W"
]

The current Ruff version

0.7.4

Metadata

Metadata

Assignees

Labels

questionAsking for support or clarification

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions