{"id":8775,"library":"wemake-python-styleguide","title":"wemake-python-styleguide","description":"wemake-python-styleguide is an extremely strict and opinionated Python linter, acting as a flake8 plugin and a companion to ruff. It aims to enforce consistent, maintainable, and less complex code, often surpassing standard PEP8 checks with its extensive rule set. The library is actively maintained with frequent minor releases, currently at version 1.6.1, and supports Python 3.10 and newer.","status":"active","version":"1.6.1","language":"en","source_language":"en","source_url":"https://github.com/wemake-services/wemake-python-styleguide","tags":["linter","styleguide","flake8","ruff","code quality","opinionated"],"install":[{"cmd":"pip install wemake-python-styleguide","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"wemake-python-styleguide is a plugin for flake8 and requires it to run its checks.","package":"flake8"},{"reason":"As of v1.0.0, wemake-python-styleguide is designed as a 'ruff companion'. It delegates many checks and formatting tasks to ruff, making ruff an essential tool for the complete intended linting experience.","package":"ruff","optional":true},{"reason":"Required Python interpreter version range.","package":"python","version":">=3.10, <4.0","optional":false}],"imports":[{"note":"wemake-python-styleguide is primarily used as a flake8 plugin or via its CLI for specific utilities like `wps explain` to look up violation documentation locally. It is not typically imported into Python code for direct use.","symbol":"CLI tool","correct":"wps explain <code>"},{"note":"Users typically interact with wemake-python-styleguide indirectly through the flake8 CLI, not by directly importing it as a Python module. The '--select=WPS' flag is crucial for activating its rules.","wrong":"import wemake_python_styleguide","symbol":"flake8 integration","correct":"flake8 --select=WPS ."}],"quickstart":{"code":"pip install wemake-python-styleguide flake8 ruff\n\n# --- pyproject.toml ---\n# [tool.ruff]\n# line-length = 88 # Or your preferred length\n# target-version = \"py310\"\n#\n# [tool.flake8]\n# select = \"WPS\"\n# max-complexity = 10\n# max-line-length = 88\n\n# Run ruff first for formatting and many common lints\nruff format .\nruff check .\n\n# Then run wemake-python-styleguide specific checks via flake8\nflake8 --select=WPS .","lang":"bash","description":"Install `wemake-python-styleguide` alongside `flake8` and `ruff`. Create a `pyproject.toml` (for Ruff configuration) and/or `setup.cfg` (for Flake8 configuration, including `--select=WPS`). The recommended workflow involves running `ruff format`, `ruff check`, and then `flake8 --select=WPS` sequentially. This ensures Ruff handles most style and formatting, leaving wemake-python-styleguide to apply its unique opinionated rules."},"warnings":[{"fix":"Ensure you install and configure 'ruff' (e.g., in `pyproject.toml`) and run `ruff format && ruff check` before `flake8 --select=WPS`. Review the v1.0.0 changelog for removed WPS codes.","message":"Version 1.0.0 introduced a significant breaking change by shifting to 'ruff compatibility'. Many rules previously handled by wemake-python-styleguide (and its internal flake8 plugins) were removed and are now expected to be covered by ruff. Users must integrate ruff into their workflow alongside flake8.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Start with the default configuration, then systematically address or disable specific rules (e.g., using `# noqa` comments, `per-file-ignores`, or `ignore =` in `setup.cfg`) until your codebase passes. Refer to the documentation for each WPS code.","message":"wemake-python-styleguide is exceptionally strict and opinionated. New users will almost certainly encounter a large number of violations, even on well-written code, and will need to carefully configure ignored rules in `setup.cfg` or `pyproject.toml`.","severity":"gotcha","affected_versions":"All"},{"fix":"Always include `ruff format .`, `ruff check .`, and `flake8 --select=WPS .` in your CI/CD pipelines and local pre-commit hooks. Adjust configuration files (e.g., `pyproject.toml` for `ruff`, `setup.cfg` for `flake8`) to match.","message":"The complete linting experience now relies on running *both* `ruff` and `flake8 --select=WPS`. Simply running `flake8` without `ruff` (or without `--select=WPS`) will result in an incomplete set of checks and missed violations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review your `flake8` configuration (`setup.cfg`, `.flake8`) and remove any `WPS` codes explicitly listed as removed in the v1.0.0 changelog. Use `ruff`'s corresponding rule codes instead where applicable.","message":"Many specific WPS violation codes were removed in v1.0.0 because their checks are now handled by ruff or pylint. Relying on these old codes in configurations will no longer have an effect.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Instead of sprinkling `# noqa` comments, try to refactor code to adhere to the style guide, or disable specific rules globally or per-file in your `setup.cfg` if they truly do not fit your project's needs.","message":"The linter actively discourages excessive use of `# noqa` comments. The `WPS402` rule will flag modules with too many such comments, indicating potential issues with code quality or over-ignoring rules.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Add `# -*- coding: utf-8 -*-` (or similar) as the first or second line of your Python files.","cause":"The Python file is missing a coding magic comment (e.g., `# -*- coding: utf-8 -*-`) at the top, which wemake-python-styleguide enforces.","error":"C101 Coding magic comment not found"},{"fix":"Ensure all Python files end with a single newline character. Most IDEs can be configured to do this automatically on save.","cause":"The linter detected that a file does not end with a newline character, a common PEP8 violation.","error":"C0304 Final newline missing"},{"fix":"Refactor the class to reduce the number of methods, often by extracting related functionality into smaller helper classes or functions. Adjust the `max-methods` option in your `flake8` configuration if the default is too restrictive for your project.","cause":"The linter is enforcing a strict maximum number of methods per class (default 6), indicating potential violation of the Single Responsibility Principle.","error":"WPS214 Too many methods in a class (7 > 6)"},{"fix":"Refactor the function into smaller, more focused units, or use data structures to group related variables. Adjust the `max-local-variables` option in your `flake8` configuration if the default is too restrictive.","cause":"A function or method exceeds the maximum allowed number of local variables (default 4), suggesting excessive complexity or too many responsibilities.","error":"WPS210 Too many local variables (5 > 4)"},{"fix":"Ensure `flake8` is installed (`pip install flake8`). Always specify `--select=WPS` directly after `flake8` if using it from the command line, or configure `select = WPS` in your `setup.cfg` or `pyproject.toml` under the `[flake8]` section.","cause":"wemake-python-styleguide is installed, but flake8 is not detecting the 'WPS' selection option, likely because `flake8` itself is not installed or incorrectly configured, or `--select=WPS` is not the first argument when used with other flake8 arguments.","error":"flake8: error: unrecognized arguments: --select=WPS"}]}