Formatter

Our very own flake8 formatter for better error messages.

That’s how all flake8 formatters work:

graph LR F2[start] --> F3[after_init] F3 --> F4[start] F4 --> F5[beggining] F5 --> F6[handle] F6 --> F7[format] F6 --> F8[show_source] F6 --> F9[show_statistic] F7 --> F10[finished] F8 --> F10[finished] F9 --> F10[finished] F10 -.-> F5 F10 --> F11[stop]

flake8 formatting API calls order.

class WemakeFormatter(options)[source]

Bases: flake8.formatting.base.BaseFormatter

We need to format our style violations beatifully.

The default formatter does not allow us to do that. What things do we miss?

  1. Spacing, everything is just mixed up and glued together

  2. Colors and decoration, some information is easier to gather just with colors or underlined text

  3. Grouping, we need explicit grouping by filename

  4. Incomplete and non-informative statistics

after_init()[source]

Called after the original init is used to set extra fields.

handle(error)[source]

Processes each violation to print it and all related.

Return type

None

format(error)[source]

Called to format each individual violation.

Return type

str

show_source(error)[source]

Called when --show-source option is provided.

Return type

str

show_statistics(statistics)[source]

Called when --statistic option is passed.

Return type

None

stop()[source]

Runs once per app when the formatting ends.

Return type

None