pylama 0,0 travis-ci python

Code audit tool for python.

3 years after

|logo| Pylama #############

.. _description:

Code audit tool for Python and JavaScript. Pylama wraps these tools:

  • PEP8_ © 2012-2013, Florent Xicluna;
  • pydocstyle_ (formerly pep257 by Vladimir Keleshev) © 2014, Amir Rachum;
  • PyFlakes_ © 2005-2013, Kevin Watters;
  • Mccabe_ © Ned Batchelder;
  • Pylint_ © 2013, Logilab (should be installed 'pylama_pylint' module);
  • gjslint_ © The Closure Linter Authors (should be installed 'pylama_gjslint' module);

.. _badges:

.. image:: :target: :alt: Build Status

.. image:: :target: :alt: Coverals

.. image:: :target: :alt: Version

.. image:: :target: :alt: Donate

.. _documentation:

Docs are available at Pull requests with documentation enhancements and/or fixes are awesome and most welcome.

.. _contents:

.. contents::

.. _requirements:


  • Python (2.6, 2.7, 3.2, 3.3)
  • To use JavaScript checker (gjslint) you need to install python-gflags with pip install python-gflags.
  • If your tests are failing on Win platform you are missing: curses - (The curses library supplies a terminal-independent screen-painting and keyboard-handling facility for text-based terminals)

.. _installation:


Pylama could be installed using pip: :: ::

$ pip install pylama

.. _quickstart:


Pylama is easy to use and really fun for checking code quality. Just run pylama and get common output from all pylama plugins (PEP8, PyFlakes and etc)

Recursive check the current directory. ::

$ pylama

Recursive check a path. ::

$ pylama <path_to_directory_or_file>

Ignore errors ::

$ pylama -i W,E501

.. note:: You could choose a group erros D,E1 and etc or special errors C0312

Choose code checkers ::

$ pylama -l "pep8,mccabe"

Choose code checkers for JavaScript::

$ pylama --linters=gjslint --ignore=E:0010 <path_to_directory_or_file>

.. _options:

Set Pylama (checkers) options

Command line options


$ pylama --help

usage: pylama [-h] [--verbose] [--version] [--format {pep8,pylint}]
              [--select SELECT] [--sort SORT] [--linters LINTERS]
              [--ignore IGNORE] [--skip SKIP] [--report REPORT] [--hook]
              [--async] [--options OPTIONS] [--force] [--abspath]
              [paths [paths ...]]

Code audit tool for python.

positional arguments:
  paths                 Paths to files or directories for code check.

optional arguments:
  -h, --help            show this help message and exit
  --verbose, -v         Verbose mode.
  --version             show program's version number and exit
  --format {pep8,pylint}, -f {pep8,pylint}
                        Choose errors format (pep8, pylint).
  --select SELECT, -s SELECT
                        Select errors and warnings. (comma-separated list)
  --sort SORT           Sort result by error types. Ex. E,W,D
  --linters LINTERS, -l LINTERS
                        Select linters. (comma-separated). Choices are
  --ignore IGNORE, -i IGNORE
                        Ignore errors and warnings. (comma-separated)
  --skip SKIP           Skip files by masks (comma-separated, Ex.
  --report REPORT, -r REPORT
                        Send report to file [REPORT]
  --hook                Install Git (Mercurial) hook.
  --async               Enable async mode. Usefull for checking a lot of
                        files. Dont supported with pylint.
  --options OPTIONS, -o OPTIONS
                        Select configuration file. By default is
  --force, -F           Force code checking (if linter doesnt allow)
  --abspath, -a         Use absolute paths in output.

.. _modeline:

File modelines

You can set options for Pylama inside a source files. Use pylama modeline for this.

Format: ::

# pylama:{name1}={value1}:{name2}={value2}:...


 .. Somethere in code
 # pylama:ignore=W:select=W301

Disable code checking for current file: ::

 .. Somethere in code
 # pylama:skip=1

The options have a must higher priority.

.. _skiplines:

Skip lines (noqa)

Just add # noqa in end of line for ignore.


def urgent_fuction():
    unused_var = 'No errors here' # noqa

.. _config:

Configuration files

When starting Pylama try loading configuration file.

The programm searches for the first matching ini-style configuration file in the directories of command line argument. Pylama looks for the configuration in this order: ::


You could set configuration file manually by "-o" option.

Pylama search sections with name starts pylama.

Section pylama contains a global options, like linters and skip.


format = pylint
skip = */.tox/*,*/.env/*
linters = pylint,mccabe
ignore = F0401,C0111,E731

Set Code-checkers' options

You could set options for special code checker with pylama configurations.


builtins = _

max_line_length = 100

max_line_length = 100
disable = R

See code checkers documentation for more info.

Set options for file (group of files)

You could set options for special file (group of files) with sections:

The options have a higher priority than in the pylama section.


ignore = C901,R0914,W0212
select = R

ignore = C0110

skip = 1

Pytest integration

Pylama have Pytest_ support. The package automatically register self as pytest plugin when during installation. Also pylama suports pytest_cache plugin.

Check files with pylama ::

pytest --pylama ...

Recomended way to settings pylama options when using pytest — configuration files (see below).

Writing a linter

You can write a custom extension for Pylama. Custom linter should be a python module. Name should be like 'pylama_'.

In '' should be defined 'pylama.linter' entry point. ::

    # ...
        'pylama.linter': ['lintername = pylama_lintername.main:Linter'],
    # ...

'Linter' should be instance of 'pylama.lint.Linter' class. Must implemented two methods:

'allow' take a path and returned true if linter could check this file for errors. 'run' take a path and meta keywords params and return list of errors.


Just virtual 'WOW' checker. ::

    install_requires=[ 'setuptools' ],
        'pylama.linter': ['wow = pylama_wow.main:Linter'],
    # ...
) ::

from pylama.lint import Linter as BaseLinter

class Linter(BaseLinter):

    def allow(self, path):
        return 'wow' in path

    def run(self, path, **meta):
        with open(path) as f:
            if 'wow' in
                return [{
                    lnum: 0,
                    col: 0,
                    text: 'Wow has been finded.',
                    type: 'WOW'

Run pylama from python code


from pylama.main import check_path, parse_options

my_redefined_options = {...}
my_path = '...'
options = parse_options([my_path], **my_redefined_options)
errors = check_path(options)

.. _bagtracker:

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at

.. _contributing:


Development of adrest happens at GitHub:

.. _contributors:

Contributors ^^^^^^^^^^^^


.. _license:


Licensed under a BSD license_.

.. _links:

.. _AUTHORS: .. _BSD license: .. _Mccabe: .. _pydocstyle: .. _PEP8: .. _PyFlakes: .. _Pylint: .. _Pytest: .. _gjslint: .. _klen: .. |logo| image:: :width: 100

Related Repositories



A curated list of awesome Python frameworks, libraries, software and resources ...



Python资源大全中文版,包括:Web框架、网络爬虫、模板引擎、数据库、数据可视化、图片处理等,由伯乐在线持续更新。 ...



Vim python-mode. PyLint, Rope, Pydoc, breakpoints from box. ...



A curated list of delightful Atom packages and resources. ...



StandAlone Async cross-platform Unicode-ready Python3-ready Minifier for the Web ...

Top Contributors

klen blueyed lukaszpiotr luzfcb aequitas gmist jotes fizyk mruwnik gotcha AnkurDedania bubenkoff jeffwidman rojun famousgarkin bronsen michael-k ravipudi trojkat MrShark


-   7.1.0 zip tar
-   7.0.9 zip tar
-   7.0.8 zip tar
-   7.0.7 zip tar
-   7.0.6 zip tar
-   7.0.5 zip tar
-   7.0.4 zip tar
-   7.0.3 zip tar
-   7.0.2 zip tar
-   7.0.1 zip tar
-   7.0.0 zip tar
-   6.5.0 zip tar
-   6.4.0 zip tar
-   6.3.4 zip tar
-   6.3.3 zip tar
-   6.3.2 zip tar
-   6.3.1 zip tar
-   6.3.0 zip tar
-   6.2.0 zip tar
-   6.1.2 zip tar
-   6.1.1 zip tar
-   6.1.0 zip tar
-   6.0.1 zip tar
-   6.0.0 zip tar
-   5.0.5 zip tar
-   5.0.4 zip tar
-   5.0.3 zip tar
-   5.0.2 zip tar
-   5.0.1 zip tar
-   5.0.0 zip tar