Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule PT019 Treats Unused Mocks as Fixtures when prefixed with underscores #7000

Open
max-muoto opened this issue Aug 30, 2023 · 2 comments
Open
Labels
bug Something isn't working

Comments

@max-muoto
Copy link
Contributor

max-muoto commented Aug 30, 2023

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 max-muoto changed the title Rule PT004 Treats Unused Mocks as Fixtures Rule PT019 Treats Unused Mocks as Fixtures Aug 30, 2023
@max-muoto max-muoto changed the title Rule PT019 Treats Unused Mocks as Fixtures Rule PT019 Treats Unused Mocks as Fixtures when prefixed with underscore Aug 30, 2023
@max-muoto max-muoto reopened this Aug 30, 2023
@max-muoto max-muoto changed the title Rule PT019 Treats Unused Mocks as Fixtures when prefixed with underscore Rule PT019 Treats Unused Mocks as Fixtures when prefixed with underscores Aug 30, 2023
@max-muoto
Copy link
Contributor Author

max-muoto commented Aug 30, 2023

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

@charliermarsh charliermarsh added the bug Something isn't working label Sep 19, 2023
@jamesbraza
Copy link
Contributor

There is a similar issue in the upstream: m-burst/flake8-pytest-style#202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants