LinuxCommandLibrary

flake8

Python code linter and style checker

TLDR

Check Python file

$ flake8 [file.py]
copy
Check directory
$ flake8 [src/]
copy
Show specific errors
$ flake8 --select=[E,W] [file.py]
copy
Ignore specific errors
$ flake8 --ignore=[E501] [file.py]
copy
Set max line length
$ flake8 --max-line-length=[120] [file.py]
copy

SYNOPSIS

flake8 [options] [files...]

DESCRIPTION

flake8 is a Python linting tool combining PyFlakes, pycodestyle, and McCabe complexity checker. It finds programming errors, style issues, and overly complex code.
The tool enforces PEP 8 style guidelines and catches common errors like undefined variables, unused imports, and syntax problems. Plugins extend checking for additional frameworks and patterns.
flake8 integrates with editors, CI pipelines, and pre-commit hooks for automated code quality enforcement.

PARAMETERS

FILES

Python files or directories to check.
--select ERRORS
Check only specific error codes.
--ignore ERRORS
Ignore specific error codes.
--max-line-length N
Maximum line length (default 79).
--exclude PATTERNS
Exclude matching files/directories.
--config FILE
Configuration file.
--format FORMAT
Output format.
--help
Display help information.

CONFIGURATION

setup.cfg

Project-level flake8 configuration in the [flake8] section.
.flake8
Dedicated flake8 configuration file for project settings.
~/.config/flake8
User-level global configuration file.

CAVEATS

Strict defaults may require customization. Some checks overlap with other tools. Plugin ecosystem varies in quality.

HISTORY

flake8 was created by Tarek Ziadé to unify Python linting tools. It wraps multiple checkers under a single interface with consistent configuration and output.

SEE ALSO

pylint(1), black(1), ruff(1)

> TERMINAL_GEAR

Curated for the Linux community

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99
Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50