Linux command
flake8 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Check Python file
flake8 [file.py]
Check directory
flake8 [src/]
Show specific errors
flake8 --select=[E,W] [file.py]
Ignore specific errors
flake8 --ignore=[E501] [file.py]
Set max line
flake8 --max-line-length=[120] [file.py]
说明
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.
参数
- --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.
FAQ
What is the flake8 command used for?
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.
How do I run a basic flake8 example?
Run `flake8 [file.py]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --select _ERRORS_ do in flake8?
Check only specific error codes.