{"id":561,"library":"pycodestyle","title":"pycodestyle: Python Style Guide Checker","description":"pycodestyle is a tool designed to check Python code against a subset of the style conventions outlined in PEP 8. It's a widely adopted package within the Python ecosystem, helping developers maintain consistent and readable code. The current version is 2.14.0, and the project is actively maintained with regular updates.","status":"active","version":"2.14.0","language":"python","source_language":"en","source_url":"https://github.com/PyCQA/pycodestyle","tags":["linter","code quality","PEP 8","style guide","static analysis"],"install":[{"cmd":"pip install pycodestyle","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Runtime dependency for the checker logic.","package":"python","optional":false}],"imports":[{"note":"The package was renamed from 'pep8' to 'pycodestyle' to avoid confusion and better reflect its purpose as a tool, not the style guide itself.","wrong":"import pep8","symbol":"pycodestyle","correct":"import pycodestyle"},{"note":"Used for programmatic checking of files or directories, often with custom configurations.","symbol":"StyleGuide","correct":"from pycodestyle import StyleGuide"},{"note":"Used for programmatic checking of a single file.","symbol":"Checker","correct":"from pycodestyle import Checker"}],"quickstart":{"code":"import pycodestyle\nimport os\n\ndef create_example_file(filename):\n    with open(filename, 'w') as f:\n        f.write(\"import os, sys  # E401 multiple imports on one line\\n\")\n        f.write(\"\\n\")\n        f.write(\"def my_function(  ): # E201 whitespace after '('\")\n        f.write(\"    pass\\n\")\n\nexample_file = 'example_code.py'\ncreate_example_file(example_file)\n\n# Programmatic checking using StyleGuide\nstyle_checker = pycodestyle.StyleGuide(quiet=True)\nreport = style_checker.check_files([example_file])\n\nif report.total_errors:\n    print(f\"Found {report.total_errors} code style errors.\")\n    # For detailed output, you might remove quiet=True or configure the report object\n    # For simplicity, this example only prints the total.\nelse:\n    print(\"No code style errors found.\")\n\n# Clean up the example file\nos.remove(example_file)","lang":"python","description":"This quickstart demonstrates how to programmatically use `pycodestyle`'s `StyleGuide` class to check a Python file for PEP 8 compliance. It creates a temporary file with some common style violations, runs the checker, and reports the total number of errors found. You can also run `pycodestyle` directly from the command line: `pycodestyle your_file.py`."},"warnings":[{"fix":"Update all `import pep8` statements to `import pycodestyle` or `from pycodestyle import ...`.","message":"The package was renamed from `pep8` to `pycodestyle`. Projects still importing `pep8` will fail when upgrading or installing `pycodestyle`.","severity":"breaking","affected_versions":"<=1.7.1 (pep8) to >=2.0.0 (pycodestyle)"},{"fix":"Ensure your project is running on Python 3.9 or a newer compatible version. Consider using `pyenv` or virtual environments to manage Python versions.","message":"`pycodestyle` dropped support for older Python versions. As of version 2.14.0, it requires Python 3.9 or newer.","severity":"breaking","affected_versions":">=2.9.0 (dropped Python 2.7/3.5); >=2.14.0 (requires >=3.9)"},{"fix":"Rename `[pep8]` sections in your configuration files to `[pycodestyle]`.","message":"Configuration files (`setup.cfg`, `tox.ini`, `pyproject.toml`) now expect a `[pycodestyle]` section for configuration, not `[pep8]`.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Integrate `flake8` with relevant plugins for broader code quality checks if naming or docstring conventions are desired. `pip install flake8 pep8-naming pydocstyle`.","message":"`pycodestyle` only checks for a subset of PEP 8 style conventions (e.g., indentation, whitespace, line length). It deliberately does *not* cover other aspects like naming conventions or docstring conventions. For a more comprehensive linting solution, consider tools like `flake8` (which uses `pycodestyle` internally) with appropriate plugins (e.g., `pep8-naming`, `pydocstyle`).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T15:08:42.773Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Refactor the long line into multiple shorter lines, use implicit string concatenation for long strings, or configure pycodestyle to increase the --max-line-length (e.g., `pycodestyle --max-line-length=120`) or ignore the error with `# noqa: E501` on the line.","cause":"A line of code exceeds the maximum allowed character length, which defaults to 79 characters according to PEP 8.","error":"E501 line too long (X > Y characters)"},{"fix":"Add a blank line at the very end of your `.py` file.","cause":"The Python source file does not end with a single blank line.","error":"W292 no newline at end of file"},{"fix":"Place each import statement on its own separate line.","cause":"Multiple modules are imported on a single line using a comma-separated list, which violates PEP 8.","error":"E401 multiple imports on one line"},{"fix":"Remove the unused import statement. If it's an `__init__.py` file and the import is intended for re-export, add the name to the module's `__all__` variable to explicitly declare it as part of the public API, or use `# noqa: F401` to suppress the warning for that specific line.","cause":"A module or name has been imported into the file but is not subsequently used within the code. While technically a Pyflakes error, it's commonly reported when using tools like Flake8, which integrates pycodestyle and pyflakes.","error":"F401 'module' imported but unused"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":1.7,"disk_size":"17.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.7,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.12,"mem_mb":1.9,"disk_size":"19.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":1.9,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":2,"disk_size":"11.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":2.2,"disk_size":"11.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":1.7,"disk_size":"17.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.7,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}