Comments (5)
Hi James,
Thanks for raising this.
Since this plugin is based on flake8, and flake8 itself does not provide any infrastructure for automatic fixing of lint errors, this would have to be implemented from scratch, and I am not sure I have the capacity for this in the foreseeable future.
In the meantime, I would like to note two things.
1 — rules such as PT001
and PT006
are configurable, and if your project(s) have a consistent code style but it is different from our default, you can simply use non-default config values. The supported configuration options are listed in the readme.
2 — there are flake8 plugins/wrappers which are specifically designed to adopt flake8 into existing codebases. One of them is flakehell
, which introduces a concept of baseline. I do not have any firsthand experience with such tools, but they might prove useful in your case.
from flake8-pytest-style.
Also, as mentioned in pytest-dev/pytest#10709 (comment), the rules from flake8-pytest-style are available in Ruff with some autofixes, including PT001
and PT006
from flake8-pytest-style.
@jamesbraza Ruff is capable of automating these fixes.
However, it is worth noting that PT001
runs counter to the example usage in the pytest docs.
from flake8-pytest-style.
Hi @cclauss,
As mentioned in my comment above and in the docs for PT001, it is configurable: you can change the flag in your flake8 config to invert the rule behavior.
from flake8-pytest-style.
I thought pytest docs usage examples would be the default behavior and that deviations would require special settings.
I will use pytest-fixture-no-parentheses
so that my code matches the pytest docs. Thanks.
from flake8-pytest-style.
Related Issues (20)
- When I have dictionaries with different insert order in test, PT014 happens HOT 1
- I want a rule that will find tests without assert statements HOT 1
- False positive PT019 with monkey patching and _ in test signature HOT 2
- False positive PT009 for unittest.TestCase.assertRaises HOT 5
- Review assertion method names for PT009/PT027
- Research PT009 for Django assertions HOT 1
- When I have pytest.fail() in a test, it is incorrectly detected as a unittest-style assertion HOT 1
- I want a rule that will check use of `argnames` and `argvalues` in `@pytest.mark.parametrize` HOT 1
- I want a rule that will flag Exception in raises() contexts. HOT 2
- I want a rule that will disallow patching `os.environ` with `mock.patch.dict`
- I want a rule that will check pytest.approx parameters
- PT017 violated in non-test code HOT 2
- I want a rule that will check that aren't parenthesis opening characters in tests ids
- I want a rule that will catch `@pytest.mark.django_db()()`
- I want a rule that will detect unused fixture as argument and instruct to use pytest.mark.usefixtures instead
- Rule that suggests explicit `strict=` in `@pytest.mark.xfail` HOT 2
- reverse pytest-mark-no-parenthese and pytest-fixture-no-parentheses HOT 6
- Only enable flake-pytest-style when pytest is in use HOT 1
- [false-positive][PT019] When I have a test with an underscored parameter name, it incorrectly suggests switching to `usefixtures` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flake8-pytest-style.