Skip to content

Instantly share code, notes, and snippets.

@izikeros
Last active July 14, 2025 23:04
Show Gist options
  • Select an option

  • Save izikeros/c938c49f5ad38dcc74a5671e85f694e7 to your computer and use it in GitHub Desktop.

Select an option

Save izikeros/c938c49f5ad38dcc74a5671e85f694e7 to your computer and use it in GitHub Desktop.
[flake8 configuration] Configuration for Flake8 with plugins: flake8-bugbear, flake8-commas, flake8-docstrings, flake8-print, flake8-pytest, flake8-pytest-mark #qa #python #project #configuration
; Configuration for Flake8 with plugins:
; flake8-bugbear,
; flake8-commas,
; flake8-docstrings,
; flake8-print,
; flake8-pytest,
; flake8-pytest-mark
; flake8-import-order
[flake8]
;[M502] test definition not marked with test_type
;[N802] function name 'setUpTestData' should be lowercase
;[F405] xyz may be undefined, or defined from star imports
;[T001] print found.
;[D100] Missing docstring in public module
;[D101] Missing docstring in public class (e.g. Models' Meta)
;[D102] Missing docstring in public method
;[D104] Missing docstring in public package
;[D105] Missing docstring in magic method
;[D107] Missing docstring in __init__
;[E402] module level import not at top of file
;[E203] whitespace before ':'
;[W503] line break before binary operator (incompatibility between flake8 and black)
;[FKA01] <function_name> call uses <X> positional arguments, use keyword arguments.
; this should be not excluded in more mature version
; [D103] Missing docstring in public function
;Violation families (can be excluded or selected)
;B - flake8-bugbear
;C - complexity
;D - flake8-docstrings
;F - ?
;N - ?
;T - flake8-print
;M - flake8-pytest-mark
ignore =C, T003, M502, N802, F405, T001, D100, D101, D104, D105, D107, E203, W503
#select = B
# Do not expect extensive documentation in tests
per-file-ignores =
./tests/*:D100,D101,D102,D103
exclude =
.tox,
.git,
*staticfiles*,
locale,
docs,
tools,
venv,
*migrations*,
*.pyc,
.git,
__pycache__,
test_*.py
;enable docstrings for tests eventually
max-line-length = 130
;Set the maximum allowed McCabe complexity value for a block of code.
max-complexity = 10
;Select the formatter used to display errors to the user.
format = pylint
;display source code lines that violate rules
show_source = False
;count violations by type
statistics = False
;total count of violations
count = True
;import style order for flake8-import-order plugin
import-order-style = pep8

Flake8 Configuration

MIT license

This README provides documentation for the Flake8 configuration file present in the following gist: https://gist.github.com/izikeros/c938c49f5ad38dcc74a5671e85f694e7. The configuration file includes settings for Flake8 and several plugins. Flake8 is a tool that performs static code analysis to identify and report code style and potential programming errors in Python.

Installation

Before using Flake8, make sure you have it installed. You can install Flake8 using pip:

pip install flake8

Configuration

The Flake8 configuration file specifies various settings to customize the behavior of Flake8 and its associated plugins. The configuration file uses the INI file format with sections and key-value pairs.

To use this configuration, create a file named .flake8 in your project directory and copy the contents of the gist into that file.

Plugins

The configuration in the gist includes the following Flake8 plugins:

  • flake8-bugbear
  • flake8-commas
  • flake8-docstrings
  • flake8-print
  • flake8-pytest
  • flake8-pytest-mark
  • flake8-import-order

These plugins enhance the functionality of Flake8 by providing additional checks and rules for code quality and style.

Flake8 Configuration

The [flake8] section in the configuration file contains settings specific to Flake8 itself:

  • ignore: This option specifies a comma-separated list of violation families and codes to ignore. Violations belonging to these families or matching the specified codes will not be reported.
  • per-file-ignores: Here, you can define specific violations to ignore for particular files or file patterns.
  • exclude: This option allows you to specify files or directories to exclude from Flake8 analysis.
  • max-line-length: Sets the maximum allowed length for a line of code.
  • max-complexity: Defines the maximum allowed McCabe complexity value for a block of code.
  • format: Specifies the formatter to use when displaying errors to the user.
  • show_source: Determines whether to display source code lines that violate rules.
  • statistics: Enables or disables statistics output, which counts the number of violations by type.
  • count: Specifies whether to display a total count of violations.
  • import-order-style: Defines the import style order for the flake8-import-order plugin.

Refer to the comments within the configuration file for more details on each option and its purpose.

Usage

To run Flake8 with this configuration, navigate to your project directory in the terminal and execute the following command:

flake8

Flake8 will analyze your Python code and report any violations based on the rules and settings specified in the configuration file.

You can also customize Flake8 further by modifying the configuration file according to your project's needs. For more information about Flake8 and its usage, please refer to the official Flake8 documentation.

License

The configuration file in this gist is provided under the terms of the MIT License. Feel free to use, modify, and distribute it as per the license terms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment