ruff icon indicating copy to clipboard operation
ruff copied to clipboard

Rule PT019 Treats Unused Mocks as Fixtures when prefixed with underscores

Open max-muoto opened this issue 2 years ago • 2 comments

Rule PT019 flags unused mock arguments prefixed with underscores as Pytest fixtures.

Example

from unittest import mock

# `_func` gets treated as unused fixture, failing a `ruff check`.
@mock.patch("func")
def test(_func):
    assert 1 == 1

Details

  • Ruff version: v0.0.286
  • Command: ruff check .

max-muoto avatar Aug 30 '23 02:08 max-muoto

@charliermarsh Understand this is probably just due to fixture naming conventions, but just thought I would flag in case!

max-muoto avatar Aug 30 '23 02:08 max-muoto

There is a similar issue in the upstream: https://github.com/m-burst/flake8-pytest-style/issues/202

jamesbraza avatar Mar 26 '24 00:03 jamesbraza