Convert Figma logo to code with AI

wemake-services logowemake-python-styleguide

The strictest and most opinionated python linter ever!

2,493
381
2,493
127

Top Related Projects

3,391

flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.

38,528

The uncompromising Python code formatter

5,236

It's not just a linter that annoys you!

13,726

A formatter for Python files

30,822

An extremely fast Python linter and code formatter, written in Rust.

Quick Overview

The wemake-python-styleguide is a strict, opinionated linter for Python code. It enforces a large set of style and quality rules, aiming to make Python code more consistent, readable, and maintainable. This tool is designed to be used as part of a continuous integration pipeline and can be integrated with various code editors and IDEs.

Pros

  • Extremely comprehensive, covering a wide range of Python coding issues
  • Highly customizable with numerous configuration options
  • Integrates well with popular development tools and CI/CD pipelines
  • Promotes consistent and high-quality code across projects and teams

Cons

  • Can be overwhelming for beginners due to its strict nature
  • May require significant initial setup and configuration
  • Some rules might be too opinionated for certain projects or coding styles
  • Can potentially slow down the development process if not properly configured

Getting Started

To get started with wemake-python-styleguide, follow these steps:

  1. Install the package using pip:
pip install wemake-python-styleguide
  1. Create a configuration file (e.g., setup.cfg) in your project root:
[flake8]
max-line-length = 80
ignore = WPS305, WPS306
per-file-ignores =
    __init__.py: WPS410, WPS412
  1. Run the linter on your Python files:
flake8 your_python_file.py

You can also integrate it with your editor or IDE for real-time linting. Refer to the project's documentation for more detailed configuration options and usage instructions.

Competitor Comparisons

3,391

flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.

Pros of flake8

  • Lightweight and fast, with minimal configuration required
  • Highly extensible through plugins, allowing customization
  • Well-established in the Python community with broad adoption

Cons of flake8

  • Less opinionated, requiring more manual configuration for strict checks
  • May miss some complex code quality issues that wemake-python-styleguide catches
  • Default configuration is relatively permissive compared to wemake-python-styleguide

Code Comparison

flake8:

def example_function(param1, param2):
    result = param1 + param2
    return result

wemake-python-styleguide:

def example_function(param1: int, param2: int) -> int:
    """Add two integers and return the result."""
    return param1 + param2

The wemake-python-styleguide example enforces type annotations and encourages docstrings, while flake8's default configuration allows more flexibility but potentially less clarity.

Both tools aim to improve code quality, but wemake-python-styleguide is more strict and opinionated out of the box. flake8 offers more customization options, allowing teams to tailor their linting rules to their specific needs. The choice between them depends on the desired level of strictness and the team's willingness to configure and maintain linting rules.

38,528

The uncompromising Python code formatter

Pros of Black

  • Opinionated and consistent formatting, reducing debates over code style
  • Fast execution, suitable for large codebases
  • Minimal configuration required, works out of the box

Cons of Black

  • Less flexible than wemake-python-styleguide, with fewer customization options
  • Focuses solely on formatting, not on code quality or best practices
  • May produce unexpected results in some edge cases

Code Comparison

Black:

def long_function_name(
    var_one, var_two, var_three, var_four
):
    print(var_one)

wemake-python-styleguide:

def long_function_name(
    var_one,
    var_two,
    var_three,
    var_four,
):
    print(var_one)

Black enforces a more compact style, while wemake-python-styleguide prefers a more vertical layout. The wemake-python-styleguide also enforces a trailing comma in multi-line function definitions.

Both tools aim to improve code quality and consistency, but they approach it differently. Black focuses on automatic formatting with minimal configuration, while wemake-python-styleguide provides a comprehensive set of style and quality checks with more customization options. The choice between them depends on project requirements and team preferences.

5,236

It's not just a linter that annoys you!

Pros of pylint

  • More established and widely used in the Python community
  • Highly configurable with numerous options and plugins
  • Integrates well with various IDEs and development tools

Cons of pylint

  • Can be overly verbose and produce false positives
  • Configuration can be complex and time-consuming
  • May require more setup and customization for specific project needs

Code Comparison

pylint:

# pylint: disable=missing-docstring
def example_function(arg1, arg2):
    return arg1 + arg2

wemake-python-styleguide:

"""This module contains an example function."""

def example_function(arg1: int, arg2: int) -> int:
    """Add two integers and return the result."""
    return arg1 + arg2

The wemake-python-styleguide enforces stricter typing and documentation requirements, while pylint allows for more flexibility but can be configured to enforce similar standards.

Both tools aim to improve code quality and maintainability, but wemake-python-styleguide takes a more opinionated approach with stricter defaults. pylint offers more customization options, allowing teams to tailor the linting process to their specific needs. The choice between the two depends on project requirements, team preferences, and the desired level of strictness in code style enforcement.

13,726

A formatter for Python files

Pros of YAPF

  • Highly configurable with support for various style options
  • Can reformat entire files or specific code ranges
  • Integrates well with popular editors and IDEs

Cons of YAPF

  • Less strict enforcement of coding standards compared to wemake-python-styleguide
  • May produce unexpected formatting in complex code structures
  • Doesn't provide as comprehensive code quality checks

Code Comparison

wemake-python-styleguide:

def example_function(arg1: int, arg2: str) -> bool:
    """Docstring for the function."""
    result = arg1 > len(arg2)
    return result

YAPF:

def example_function(arg1: int, arg2: str) -> bool:
    """Docstring for the function."""
    result = arg1 > len(arg2)
    return result

In this simple example, both tools produce similar results. However, wemake-python-styleguide enforces stricter rules for more complex code structures and provides additional checks for potential issues beyond just formatting.

YAPF focuses primarily on code formatting, while wemake-python-styleguide offers a more comprehensive approach to code quality and style enforcement. YAPF is more flexible and configurable, making it suitable for projects with specific formatting requirements. wemake-python-styleguide, on the other hand, provides a stricter set of rules aimed at maintaining high code quality standards across projects.

30,822

An extremely fast Python linter and code formatter, written in Rust.

Pros of Ruff

  • Significantly faster performance due to being written in Rust
  • Broader scope of linting and formatting capabilities, including auto-fixes
  • Actively maintained with frequent updates and improvements

Cons of Ruff

  • Newer project with potentially less stability compared to wemake-python-styleguide
  • May have fewer customization options for specific coding styles
  • Learning curve for users familiar with traditional Python linters

Code Comparison

wemake-python-styleguide:

from wemake_python_styleguide import Configuration, Checker

config = Configuration()
checker = Checker(config)

Ruff:

from ruff import Ruff

ruff = Ruff()
ruff.check("path/to/your/code")

Both tools aim to improve Python code quality, but Ruff offers a more streamlined approach with its single-tool philosophy. wemake-python-styleguide focuses on enforcing a specific coding style, while Ruff provides a broader range of linting and formatting options.

Ruff's speed advantage is significant for large codebases, potentially saving considerable time during development and CI/CD processes. However, wemake-python-styleguide's established presence in the Python community might make it a more comfortable choice for teams already familiar with its conventions.

Ultimately, the choice between these tools depends on project requirements, team preferences, and the balance between performance and customization needs.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

wemake-python-styleguide

wemake.services Supporters Build Status codecov Python Version wemake-python-styleguide


Welcome to the strictest and most opinionated Python linter ever.

wemake-python-styleguide logo

wemake-python-styleguide is actually a flake8 plugin with some other plugins as dependencies.

Quickstart

pip install wemake-python-styleguide

You will also need to create a setup.cfg file with the configuration.

Try it online!

We highly recommend to also use:

  • ondivi for easy integration into a legacy codebase
  • nitpick for sharing and validating configuration across multiple projects

Running

flake8 your_module.py

This app is still just good old flake8! And it won't change your existing workflow.

invocation results

See "Usage" section in the docs for examples and integrations.

We also support GitHub Actions as first class-citizens. Try it out!

Strict is the new cool

Strict linting offers the following benefits to developers and companies:

  1. Ensures consistency - no matter who works on it, the end product will always be the same dependable code
  2. Helps avoid potential bugs - strict rules make sure that you don't make common mistakes
  3. Efficient code reviews - each piece of code has a similar familiar style and syntax. If it passes all the checks, there's little left to review!
  4. Fewer code revisions - strict linting ensures that you don't have to re-write the codebase again and again
  5. Reduce code redundancy - Sometimes we write complex code as we are thinking in a certain way about a problem. The linter offers suggestions that can help simplify the code and eliminate redundant statements

What we are about

The ultimate goal of this project is to make all people write exactly the same Python code.

flake8pylintblackmypyruffwemake-python-styleguide
Formats code?❌❌✅❌✅❌
Finds style issues?🤔✅🤔❌✅✅
Finds bugs?🤔✅❌✅✅✅
Finds complex code?❌🤔❌❌✅✅
Has a lot of strict rules?❌🤔❌❌✅✅
Has a lot of plugins?✅❌❌🤔❌✅

We have several primary objectives:

  1. Significantly reduce the complexity of your code and make it more maintainable
  2. Enforce "There should be one -- and preferably only one -- obvious way to do it" rule to coding and naming styles
  3. Protect developers from possible errors and enforce best practices

You can find all error codes and plugins in the docs.

What we are not

We are not planning to do the following things:

  1. Assume or check types, use mypy together with our linter
  2. Reformat code, since we believe that developers should do that
  3. Check for SyntaxError or logical bugs, write tests instead
  4. Appeal to everyone. But, you can switch off any rules that you don't like

Supporting us :tada:

We in wemake.services make all our tools open-source by default, so the community can benefit from them. If you use our tools and they make your life easier and brings business value, you can return us a favor by supporting the work we do.

Gold Tier

Silver Tier

Bronze Tier

Show your style :sunglasses:

If you use our linter - it means that your code is awesome. You can be proud of it! And you should share your accomplishment with others by including a badge in your README file. It looks like this:

wemake-python-styleguide

Markdown

[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)

Restructured text

.. image:: https://img.shields.io/badge/style-wemake-000000.svg
   :target: https://github.com/wemake-services/wemake-python-styleguide

Contributing

We warmly welcome all contributions!

List of contributors

See "Contributing" section in the documentation if you want to contribute.

You can start with issues that need some help right now.