Flake8

Flake8 is a wrapper around these tools:

  • PyFlakes
  • pycodestyle
  • Ned Batchelder’s McCabe script

Version

3.4.1

Runtime

Python Versions

Supported Languages

Python

Official Documentation

https://pypi.python.org/pypi/flake8/3.4.1

YAML Configuration

flake8:

  • input:

    Patterns to include in execution and reports.

  • ignore:

    Patterns to exclude from execution and reports.

  • auto-fix:

    N/A

  • config-file:

    Alias of --config option.

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.75 CPU with 2880 MiB RAM.

      Inspecode automatically specifies --jobs option to Flake8 according to this value. For example, --jobs=1 is specified by default (for 0.75 CPU), --jobs=2 is specified for 1.1 CPU.

  • options:

    Below is the list of options that are supported:

    --exclude=patterns    Comma-separated list of files or directories to
                          exclude. (Default:
                          .svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg)
    --filename=patterns   Only check for filenames matching the patterns in this
                          comma-separated list. (Default: *.py)
    --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:
                          E,F,W,C90)
    --append-config=APPEND_CONFIG
                          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 found configuration files.
    --max-complexity=MAX_COMPLEXITY
                          McCabe complexity threshold
    
  • thresholds:

    • num-issues:

      In addition to general severity levels, the following tool specific severity levels can be specified:

      • F, Fatal (equivalent to general severity level critical)
      • E, Error (equivalent to general severity level error)
      • W, Warning (equivalent to general severity level warning)
      • C, Convention (equivalent to general severity level info)
      • R, Refactor (equivalent to general severity level info)
  • experimental:

    • incremental:

      true/false

      Note: The incremental analysis is disabled if any kinds of configuration files are changed. The files recognized as configuration files are as follows:

      • Configuration files:
        • Files specified in config-file field
        • Files specified to --append-config or --config options
        • If --isolated option is not specified:
          • **/setup.cfg, **/tox.ini, **/.flake8
          • If none of the above configuration files are found:
            • **/flake8

YAML Examples

  • With default options:

    inspecode:
      flake8: default
    
  • With custom machine:

    inspecode:
      flake8:
        machine:
          cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
    
  • With custom options:

    inspecode:
      flake8:
        options:
          --ignore: E4
    
  • With a configuration file:

    inspecode:
      flake8:
        config-file: ./my-flake8.ini
    

    The above configuration is equivalent to:

    inspecode:
      flake8:
        options:
          --config: ./my-flake8.ini
    

Configuration File Detection

If no configuration files are specified via config-file or options field, Inspecode first lets flake8 to find configuration files in your repository. See http://flake8.pycqa.org/en/latest/user/configuration.html about how flake8 looks for configuration files.

In addition, if flake8 cannot find any configuration files, Inspecode also walks the file tree in lexical order in your repository to find one of the following configuration files and specifies the file first found to flake8 automatically via --config option.

  • setup.cfg
  • tox.ini
  • .flake8
  • flake8

Note: Inspecode ignores specific configuration files while searching. See Configuration > Tool Configuration > Field: config-file for detail.

If the configuration file detected by Inspecode is not the one you want to use or you do not want to use any configuration files, you can disable Inspecode from detecting configuration files by explicitly setting an empty string to config-file field like below:

inspecode:
  flake8:
    config-file: ""

Resolving Dependencies

By default, no flake8 plugins are installed. But Inspecode automatically resolves the dependencies in the same manner as pytest and so you can install its plugins at runtime. See the pytest page for the details.

results matching ""

    No results matching ""