-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[flake8-pytest-style
] Test function parameters with default arguments (PT028
)
#15449
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PT028 | 95 | 95 | 0 | 0 | 0 |
Aside from that change, I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I've a few comments regarding the implementation and I think we should remove the fix.
crates/ruff_linter/src/rules/flake8_pytest_style/rules/helpers.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_pytest_style/rules/test_functions.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_pytest_style/rules/test_functions.rs
Show resolved
Hide resolved
...les/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT028.snap
Outdated
Show resolved
Hide resolved
Did you review the ecosystem changes? |
@MichaReiser Yes. There are a couple of false positives. For example: def test_parallel(num_threads=2, kwargs_list=None):
"""
Decorator to run the same function multiple times in parallel.
...
"""
... def test_server_running(
skip_provision_check: bool = False,
external_host: str = "testserver",
log_file: str | None = None,
dots: bool = False,
) -> Iterator[None]:
... These kinds of false positives can be reduced (the former would no longer be reported) by making |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the feedback.
I'm leaning towards not adding the is this a pytest file just yet because it would introduce the need for a new option for those not using the default file name patterns. We can decide to restrict the rule in the future if this comes up often. The other reason why I'm for deferring is that there are still some false negatives because many of the non-test test functions are defined in files prefixed with test_
Summary
Resolves #15412.
Test Plan
cargo nextest run
andcargo insta test
.