autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide

Version

1.4.3

Runtime

Python Versions

Supported Languages

Python

Official Documentation

https://pypi.python.org/pypi/autopep8/1.3.3

YAML Configuration

autopep8:

  • input:

    Patterns to include in execution and reports.

  • ignore:

    Patterns to exclude from execution and reports.

  • auto-fix:

    true/false

  • config-file:

    Alias of --global-config option.

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.25 CPU with 960 MiB RAM.

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

  • options:

    Below is the list of options that are supported:

    --global-config filename
                          path to a global pep8 config file; if this file does
                          not exist then this is ignored (default:
                          ~/.config/pep8)
    --ignore-local-config
                          don't look for and apply local config files; if not
                          passed, defaults are updated with any config files in
                          the project's root directory
    -p n, --pep8-passes n
                          maximum number of additional pep8 passes (default:
                          infinite)
    -a, --aggressive      enable non-whitespace changes; multiple -a result in
                          more aggressive changes
    --experimental        enable experimental fixes
    --exclude globs       exclude file/directory names that match these comma-
                          separated globs
    --ignore errors       do not fix these errors/warnings (default:
                          E226,E24,W50,W690)
    --select errors       fix only these errors/warnings (e.g. E4,W)
    --max-line-length n   set maximum allowed line length (default: 79)
    --hang-closing        hang-closing option passed to pycodestyle
    
  • thresholds:

    • num-issues:

      No tool specific severity levels are available.

  • 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 --global-config option
        • If --ignore-local-config option is not specified:
          • **/setup.cfg, **/tox.ini, **/.pep8
          • If none of the above configuration files are found:
            • **/pep8

YAML Examples

  • With default options:

    inspecode:
      autopep8: auto-fix
    
  • With custom machine:

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

    inspecode:
      autopep8:
        auto-fix: true
        options:
          --select: W
          --max-line-length: 80
    
  • With a pep8 configuration file:

    inspecode:
      autopep8:
        auto-fix: true
        config-file: ./pep8
    

    The above configuration is equivalent to:

    inspecode:
      autopep8:
        auto-fix: true
        options:
          --global-config: ./pep8
    

Configuration File Detection

If no configuration files are specified via config-file or options field, Inspecode first lets autopep8 to find configuration files in your repository.

In addition, if autopep8 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 autopep8 automatically via --global-config option.

  • setup.cfg
  • tox.ini
  • .pep8
  • pep8

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:
  autopep8:
    config-file: ""

results matching ""

    No results matching ""