flake8 [options] [<path> <path> ...]

flake8 --help


flake8 是一個命令行實用程序,用于在Python項目之間實施樣式一致性。默認情況下,它包括PyFlakes項目提供的lint檢查、PyCodeStyle項目提供的PEP-0008啟發的樣式檢查以及McCabe項目提供的McCabe復雜性檢查。如果找到并安裝了第三方擴展,它還將運行這些擴展。



flake8 --help


--version             show program's version number and exit
-h, --help            show this help message and exit
-v, --verbose         Print more information about what is happening in
                      flake8. This option is repeatable and will increase
                      verbosity each time it is repeated.
-q, --quiet           Report only file names, or nothing. This option is
--count               Print total number of errors and warnings to standard
                      error and set the exit code to 1 if total is not
--diff                Report changes only within line number ranges in the
                      unified diff provided on standard in by the user.
--exclude=patterns    Comma-separated list of files or directories to
                      exclude. (Default:
--filename=patterns   Only check for filenames matching the patterns in this
                      comma-separated list. (Default: *.py)
                      The name used when reporting errors from code passed
                      via stdin. This is useful for editors piping the file
                      contents to flake8. (Default: stdin)
--format=format       Format errors according to the chosen formatter.
--hang-closing        Hang closing bracket instead of matching indentation
                      of opening bracket's line.
--ignore=errors       Comma-separated list of errors and warnings to ignore
                      (or skip). For example, ``--ignore=E4,E51,W234``.
                      (Default: E121,E123,E126,E226,E24,E704,W503,W504)
--max-line-length=n   Maximum allowed line length for the entirety of this
                      run. (Default: 79)
--select=errors       Comma-separated list of errors and warnings to enable.
                      For example, ``--select=E4,E51,W234``. (Default:
--disable-noqa        Disable the effect of "# noqa". This will report
                      errors on lines with "# noqa" at the end.
--show-source         Show the source generate each error or warning.
--statistics          Count errors and warnings.
                      Enable plugins and extensions that are otherwise
                      disabled by default
--exit-zero           Exit with status code "0" even if there are errors.
                      Install a hook that is run prior to a commit for the
                      supported version control system.
-j JOBS, --jobs=JOBS  Number of subprocesses to use to run checks in
                      parallel. This is ignored on Windows. The default,
                      "auto", will auto-detect the number of processors
                      available to use. (Default: auto)
                      Redirect report to a file.
--tee                 Write to stdout and output-file.
                      Provide extra config files to parse in addition to the
                      files found by Flake8 by default. These files are the
                      last ones read and so they take the highest precedence
                      when multiple files provide the same option.
--config=CONFIG       Path to the config file that will be the authoritative
                      config source. This will cause Flake8 to ignore all
                      other configuration files.
--isolated            Ignore all configuration files.
--benchmark           Print benchmark information about this run of Flake8
--bug-report          Print information necessary when preparing a bug
--builtins=BUILTINS   define more built-ins, comma separated
--doctests            check syntax of the doctests
                      Run doctests only on these files
                      Skip these files when running doctests
                      McCabe complexity threshold



flake8 .


flake8 path/to/file.py


flake8 --ignore E101
flake8 --ignore E1,E202


flake8 --select E101
flake8 --select E2,E742


git diff -U0 | flake8 --diff -


flake8 --bug-report