flake8-pytest-style
A flake8 plugin checking common style issues or inconsistencies with pytest-based tests.
What it is and what it does
flake8-pytest-style is a flake8 plugin that integrates directly into your linting workflow to catch style and consistency issues specific to pytest test code. It reports over 30 distinct error codes (PT001–PT031) covering common mistakes like using @pytest.fixture() with unnecessary parentheses, overly broad exception matching in pytest.raises(), unittest-style assertions instead of pytest idioms, and fixture naming/return-value inconsistencies.
The plugin works as a flake8 extension, running automatically when you invoke flake8 on your test files. It is configurable via flake8 settings for several rules (fixture parentheses style, parametrize argument types, exception/warning matching requirements) and requires only one runtime dependency. It supports Python 3.10 through 3.14 and is actively maintained.
Use it for:
- Enforce consistent pytest fixture style across a team (e.g., @pytest.fixture vs @pytest.fixture()) via PT001/PT023.
- Catch overly broad exception handlers in pytest.raises() that could mask unrelated errors (PT011).
- Migrate from unittest-style assertions to pytest idioms automatically during code review (PT009/PT027).
- Detect fixture naming mistakes and return-value inconsistencies that indicate bugs (PT004/PT005).
- Validate parametrize decorators for correct argument types and duplicate test cases (PT006/PT007/PT014).
- Identify deprecated pytest patterns like @pytest.yield_fixture and request.addfinalizer (PT020/PT021).
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A flake8 plugin that detects and reports style inconsistencies and common mistakes in pytest-based test code, enforcing best practices for fixtures, parametrization, assertions, and exception handling.
Yes. If you use pytest and want automated style enforcement for test code, this plugin is worth installing. It has low install friction, active maintenance, no known vulnerabilities, and catches real mistakes that improve test reliability. The only caveat is that the license treatment is marked unclear in the metadata, though the description states MIT—verify the actual license before use in proprietary projects.
Install
flake8-pytest-style on PyPI
pip
pip install flake8-pytest-styleuv
uv add flake8-pytest-stylepoetry
poetry add flake8-pytest-styleInstalling flake8-pytest-style
Before you install
Low friction installation with a single lightweight runtime dependency (flake8-plugin-utils). Actively maintained with recent releases; last commit 2026-08-13 and version 2.2.0 released 2025-10-20. Requires Python 3.10 or later.
Quickstart
pip install flake8-pytest-style
# Then run flake8 on your test files:
flake8 tests/
# The plugin automatically checks for issues like:
# PT001: @pytest.fixture over @pytest.fixture()
# PT009: regular assert instead of unittest-style assertions
Requires Python 3.10 or later; flake8 must be installed and configured in your project.
Verify before relying
- Whether the license is actually MIT (description says 'MIT' but meta.license_spdx is null)
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — flake8-plugin-utils |
| Maintenance | actively maintained — 298 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 201,433/month — #9,672 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_pytest_style-2.2.0-py3-none-any.whl
Keywords: flake8, pytest
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
flake8-returnA flake8 plugin that detects and flags…
permissive · top 15,000 on PyPI
pytest-examplesA pytest plugin that finds, lints, runs, and…
permissive · top 15,000 on PyPI
pytest-raisesProvides pytest markers (@pytest.mark.raises…
unclear · top 15,000 on PyPI
wemake-python-styleguideA flake8 plugin that enforces strict,…
permissive · top 15,000 on PyPI
pylint-pytestA Pylint plugin that suppresses false-positive…
permissive · top 15,000 on PyPI
flake8-pieA flake8 plugin that detects code quality…
permissive · top 15,000 on PyPI
flake8-printA flake8 plugin that detects print statements…
permissive · top 5,000 on PyPI
flake8-noqaA flake8 plugin that validates the formatting…
copyleft · top 5,000 on PyPI
pytest-mockProvides a pytest fixture that wraps the mock…
permissive · top 1,000 on PyPI
flake8-plugin-utilsProvides base classes and utilities for writing…
permissive · top 5,000 on PyPI