{"id":8166,"library":"flake8-pytest-style","title":"flake8-pytest-style","description":"flake8-pytest-style is a flake8 plugin designed to enforce common style guidelines and identify inconsistencies within pytest-based test suites. It helps maintain clean and idiomatic pytest code by reporting a variety of style violations. The current version is 2.2.0, released in October 2025, and it maintains a somewhat regular release cadence, with major/minor updates typically every 3-9 months.","status":"active","version":"2.2.0","language":"python","source_language":"en","source_url":"https://github.com/m-burst/flake8-pytest-style","tags":["flake8","pytest","linter","code quality","testing","plugin"],"install":[{"cmd":"pip install flake8-pytest-style","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core linter that this plugin extends.","package":"flake8","optional":false},{"reason":"The testing framework whose style this plugin checks.","package":"pytest","optional":false}],"imports":[{"wrong":"import pytest","symbol":"flake8_pytest_style","correct":"import flake8_pytest_style"}],"quickstart":{"code":"import os\n\n# Create a dummy test file\nwith open('test_example.py', 'w') as f:\n    f.write(\"\"\"\nimport pytest\n\n@pytest.fixture\ndef my_fixture(scope='function'): # PT001, PT003\n    return 1\n\ndef test_example(my_fixture): # PT004\n    assert my_fixture == 1\n\n@pytest.mark.parametrize(('val'), [1,2]) # PT023, PT006\ndef test_parametrized_bad_style(val=10): # PT028\n    assert val > 0\n\ndef test_raises():\n    with pytest.raises(Exception):\n        pass # PT010, PT011, PT012\n\"\"\")\n\n# Run flake8 with the plugin enabled\n# flake8 automatically discovers installed plugins\nprint(\"\\n--- Running flake8 ---\")\nos.system(\"flake8 test_example.py\")\n\n# Clean up\nos.remove('test_example.py')","lang":"python","description":"Install the plugin, then run `flake8` as you normally would. The plugin automatically integrates with flake8 to check pytest-related style issues in your project."},"warnings":[{"fix":"If you experience new PT001 or PT023 violations, you may need to explicitly configure these options in your `flake8` configuration (e.g., `setup.cfg`, `pyproject.toml`) to match your preferred style, or update your code to include/remove parentheses as per the new default.","message":"Version 2.0.0 (released 2024-04-01) inverted the default values for `pytest-fixture-no-parentheses` (PT001) and `pytest-mark-no-parentheses` (PT023). This change aligns with the official pytest style, but may introduce many new violations upon upgrade.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure your project's Python environment meets the minimum version requirement for the `flake8-pytest-style` version you are using. Update your Python environment if necessary.","message":"The minimum Python version requirement has increased across minor and major versions. Version 2.0.0 requires Python >=3.8.1, version 2.1.0 requires Python >=3.9, and version 2.2.0 requires Python >=3.10.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"While `flake8-pytest-style` still reports these, consider if these specific rules fit your project's conventions. You can selectively ignore them via `flake8` configuration if they conflict with your established patterns or other linter's recommendations.","message":"Rules PT004 (fixture without return value should have leading underscore) and PT005 (fixture returning value should not have leading underscore) have been noted by the Ruff linter team (a popular alternative to flake8) as potentially not aligning with all pytest 'best practices'.","severity":"gotcha","affected_versions":"All"},{"fix":"Remove default values from test function parameters that are intended to receive fixtures. Fixtures should be injected without an explicit default.","message":"Rule PT028 warns against defining default values for parameters in test functions (e.g., `def test_foo(bar=42):`). Pytest's behavior is to use the default value instead of injecting a fixture if one is defined for that parameter, leading to unexpected test behavior.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'-9':66 '2.2.0':47 '2025':51 '3':65 'base':25 'cadenc':59 'clean':31 'code':35,71 'common':16 'current':44 'design':13 'enforc':15 'everi':64 'flake8':2,6,11,68 'flake8-pytest-style':1,5 'guidelin':18 'help':29 'identifi':20 'idiomat':33 'inconsist':21 'linter':70 'maintain':30,54 'major/minor':61 'month':67 'octob':50 'plugin':12,74 'pytest':3,7,24,34,69 'pytest-bas':23 'qualiti':72 'regular':57 'releas':48,58 'report':37 'somewhat':56 'style':4,8,17,41 'suit':27 'test':26,73 'typic':63 'updat':62 'varieti':39 'version':45 'violat':42 'within':22","created_at":"2026-04-16T17:00:46.552308+00:00","updated_at":"2026-04-16T17:00:46.552308+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.2.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://pypi.org/project/flake8-pytest-style","github":"https://github.com/m-burst/flake8-pytest-style","docs":null,"changelog":null,"pypi":"https://pypi.org/project/flake8-pytest-style/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}