Skip to content

lint: fix B018 failure on main - #721

Merged
RonnyPfannschmidt merged 1 commit into
pytest-dev:mainfrom
RonnyPfannschmidt:fix/ruff-b018-dunder-getattr-test
Aug 12, 2026
Merged

lint: fix B018 failure on main#721
RonnyPfannschmidt merged 1 commit into
pytest-dev:mainfrom
RonnyPfannschmidt:fix/ruff-b018-dunder-getattr-test

Conversation

@RonnyPfannschmidt

Copy link
Copy Markdown
Member

pre-commit.ci - push is failing on main (de34583) with:

B018 Found useless expression. Either assign it to a variable or remove it.
   --> testing/test_details.py:239:9
239 |         pluggy.nope

Two changes landed close together and combined into this:

  • 11ce4b9 (pre-commit autoupdate) bumped ruff v0.15.22v0.16.2, and ruff 0.16 enables flake8-bugbear in the default rule set. Bisected: 0.15.0 clean, 0.16.0 flags it. [tool.ruff.lint] extend-select does not list B, so this comes purely from the new defaults.
  • test: cover pluggy.__version__ getattr and HookCaller._remove_plugin … #718 added test_dunder_getattr_missing_raises with a bare pluggy.nope expression. That PR already fixed four other B018 sites in 237edb6, this one was missed.

The test workflow stays green because linting runs on pre-commit.ci, which is why the red status was easy to miss on merge.

Fix binds the expression to _, matching what 237edb6 did for _ = module.x.broken.

uv run pre-commit run -a and uv run pytest (144 passed) are green with this applied.

No changelog fragment — test-only lint fix, nothing user-facing.

🤖 Generated with Claude Code

ruff 0.16 enables flake8-bugbear by default, so the bare ``pluggy.nope``
expression added in pytest-dev#718 fails B018 and turns pre-commit.ci red on main.
Bind it to ``_`` like the other attribute-access checks in that test suite.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@RonnyPfannschmidt
RonnyPfannschmidt merged commit d23f110 into pytest-dev:main Aug 12, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant