Skip to content

[flake8-pytest-style] PT001/PT023 deletes comments inside the parenthesis #18770

@MeGaGiGaGon

Description

@MeGaGiGaGon

Summary

With PT001 on default no-parenthesis mode, it deletes comments inside the parenthesis playground

I'm not sure if this is an actual concern since I'm not too familiar with pytest, but I can imagine a case where this could be undesirable: If all parameters were commented out for whatever reason, and it gets removed by CI. I'm not sure if you would ever encounter this while actually using pytest.

PS ~\Desktop\New_folder>Get-Content issue.py
import pytest

@pytest.fixture(
    # TODO: use module scope
    # scope="module"
)
def my_fixture(): ...
PS ~\Desktop\New_folder>uvx ruff check issue.py --select PT --fix --diff
--- issue.py
+++ issue.py
@@ -1,7 +1,4 @@
 import pytest

-@pytest.fixture(
-    # TODO: use module scope
-    # scope="module"
-)
+@pytest.fixture
 def my_fixture(): ...

Would fix 1 error.

All of this also applies to PT023 playground

Version

ruff 0.12.0 (87f0feb 2025-06-17) + playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixesRelated to suggested fixes for violationshelp wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions