pycodestyle (formerly called pep8)

pycodestyle is a tool to check your Python code against some of the style conventions in PEP 8.

Note: This tool used to be called pep8 but was renamed to pycodestyle to reduce confusion.

Version

2.5.0

Runtime

Python Versions

Supported Languages

Python

Official Documentation

https://pypi.python.org/pypi/pycodestyle

YAML Configuration

pycodestyle:

  • 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.25 CPU with 960 MiB RAM.

  • options:

    Below is the list of options that are supported:

    -v, --verbose        print status messages, or debug with -vv
    --first              show first occurrence of each error
    --exclude=patterns   exclude files or directories which match these comma
                         separated patterns (default:
                         .svn,CVS,.bzr,.hg,.git,__pycache__,.tox)
    --filename=patterns  when parsing directories, only check filenames matching
                         these comma separated patterns (default: *.py)
    --select=errors      select errors and warnings (e.g. E,W6)
    --ignore=errors      skip errors and warnings (e.g. E4,W) (default:
                         E121,E123,E126,E226,E24,E704,W503,W504)
    --max-line-length=n  set maximum allowed line length (default: 79)
    --max-doc-length=n   set maximum allowed doc line length and perform these
                         checks (unchecked if not set)
    --hang-closing       hang closing bracket instead of matching indentation of
                         opening bracket's line
    
    Configuration:
      --config=path      user config file location
    
  • thresholds:

    • num-issues:

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

      • E, Error (equivalent to general severity level error)
      • W, Warning (equivalent to general severity level warning)
  • 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 --config option
        • **/setup.cfg, **/tox.ini
        • If none of the above configuration files are found:
          • **/.pycodestyle, **/pycodestyle

YAML Examples

  • With default options:

    inspecode:
      pycodestyle: default
    
  • With custom machine:

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

    inspecode:
      pycodestyle:
        options:
          --first:
          --max-line-length: 80
    
  • With a configuration file:

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

    The above configuration is equivalent to:

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

Configuration File Detection

If no configuration files are specified via config-file or options field, Inspecode first lets pycodestyle to find configuration files in your repository. See https://github.com/PyCQA/pycodestyle/blob/2.3.1/docs/intro.rst#configuration about how pycodestyle looks for configuration files.

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

  • setup.cfg
  • tox.ini
  • .pycodestyle
  • pycodestyle

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

results matching ""

    No results matching ""