--- id: flake8-pytest-style version: "2.2.0" license: unclear license_treatment: unclear maintenance: active --- # flake8-pytest-style — A flake8 plugin checking common style issues or inconsistencies with pytest-based tests. License: unclear · Maintenance: active · Downloads: 201.4K/mo ## 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 above — 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 pip install flake8-pytest-style uv add flake8-pytest-style poetry add flake8-pytest-style ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 201.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags flake8 pytest style checker, pytest fixture linting, pytest code quality, test code style enforcement, pytest best practices linter, flake8 plugin testing, pytest assertion checker, pytest-linting, test-quality, flake8-plugin [View on SkillFed](https://skillfed.io/packages/flake8-pytest-style) · [View on PyPI](https://pypi.org/project/flake8-pytest-style/)