Code audit tool for python.

logo Pylama

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

  • pycodestyle (formerly 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);
  • Radon © Michele Lacchia
  • gjslint © The Closure Linter Authors (should be installed 'pylama_gjslint' module);
  • eradicate © Steven Myint;
  • Mypy © Jukka Lehtosalo and contributors;
Build Status Coverals Version Donate

Docs are available at https://pylama.readthedocs.org/. Pull requests with documentation enhancements and/or fixes are awesome and most welcome.

Requirements:

  • Python (2.7, 3.4, 3.5, 3.6, 3.7)
  • 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 - http://www.lfd.uci.edu/~gohlke/pythonlibs/ (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 (pycodestyle, 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 "pycodestyle,mccabe"

Choose code checkers for JavaScript:

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

Set Pylama (checkers) options

Command line options

$ pylama --help

usage: pylama [-h] [--verbose] [--version]
              [--format {pep8,pycodestyle,pylint,parsable}] [--select SELECT]
              [--sort SORT] [--linters LINTERS] [--ignore IGNORE]
              [--skip SKIP] [--report REPORT] [--hook] [--concurrent]
              [--options FILE] [--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,pycodestyle,pylint,parsable}, -f {pep8,pycodestyle,pylint,parsable}
                        Choose errors format (pycodestyle, pylint, parsable).
  --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 mccabe,
                        pep257,pydocstyle,pep8,pycodestyle,pyflakes,pylint,iso
                        rt.
  --ignore IGNORE, -i IGNORE
                        Ignore errors and warnings. (comma-separated)
  --skip SKIP           Skip files by masks (comma-separated, Ex.
                        */messages.py)
  --report REPORT, -r REPORT
                        Send report to file [REPORT]
  --hook                Install Git (Mercurial) hook.
  --concurrent, --async
                        Enable async mode. Useful for checking a lot of files.
                        Unsupported with pylint.
  --options FILE, -o FILE
                        Specify configuration file. Looks for pylama.ini,
                        setup.cfg, tox.ini, or pytest.ini in the current
                        directory (default: None).
  --force, -F           Force code checking (if linter doesn't allow)
  --abspath, -a         Use absolute paths in output.

File modelines

You can set options for Pylama inside a source file. 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

Those options have a higher priority.

Skip lines (noqa)

Just add # noqa in end of line to ignore.

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

Configuration file

Pylama looks for a configuration file in the current directory.

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

pylama.ini
setup.cfg
tox.ini
pytest.ini

The "--option" / "-o" argument can be used to specify a configuration file.

Pylama searches for sections whose names start with pylama.

The "pylama" section configures global options like linters and skip.

[pylama]
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.

[pylama:pyflakes]
builtins = _

[pylama:pycodestyle]
max_line_length = 100

[pylama:pylint]
max_line_length = 100
disable = R

See code-checkers' documentation for more info. Let's notice that dashes are replaced by underscores (e.g. Pylint's "max-line-length" becomes "max_line_length").

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.

[pylama:*/pylama/main.py]
ignore = C901,R0914,W0212
select = R

[pylama:*/tests.py]
ignore = C0110

[pylama:*/setup.py]
skip = 1

Pytest integration

Pylama has Pytest support. The package automatically registers itself as a pytest plugin during installation. Pylama also supports pytest_cache plugin.

Check files with pylama

pytest --pylama ...

Recommended way to set 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_<name>'.

In 'setup.py', 'pylama.linter' entry point should be defined.

setup(
    # ...
    entry_points={
        'pylama.linter': ['lintername = pylama_lintername.main:Linter'],
    }
    # ...
)

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

'allow' takes a path and returns true if linter can check this file for errors. 'run' takes a path and meta keywords params and returns a list of errors.

Example:

Just a virtual 'WOW' checker.

setup.py:

setup(
    name='pylama_wow',
    install_requires=[ 'setuptools' ],
    entry_points={
        'pylama.linter': ['wow = pylama_wow.main:Linter'],
    }
    # ...
)

pylama_wow.py:

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 f.read():
                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

# Use and/or modify 0 or more of the options defined as keys in the variable my_redefined_options below.
# To use defaults for any option, remove that key completely.
my_redefined_options = {
    'linters': ['pep257', 'pydocstyle', 'pycodestyle', 'pyflakes' ...],
    'ignore': ['D203', 'D213', 'D406', 'D407', 'D413' ...],
    'select': ['R1705' ...],
    'sort': 'F,E,W,C,D,...',
    'skip': '*__init__.py,*/test/*.py,...',
    'async': True,
    'force': True
    ...
}
# relative path of the directory in which pylama should check
my_path = '...'

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

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/pylama/issues

Contributing

Development of pylama happens at GitHub: https://github.com/klen/pylama

Contributors

See AUTHORS.

License

Licensed under a BSD license.

Owner
Comments
  • New checker for JavaScript language.

    New checker for JavaScript language.

    Scope of this pull request:

    • added Closure-Linter JavaScript checker (code: https://code.google.com/p/closure-linter/source/browse/) to Pylama checkers,
    • added def gjslint callback in pylama\utils.py to handle gjslint linter request,
    • extended file extensions in main.py by .js suffix - default .py is always present due to main purpose of the tool,
    • introduced unittests in tests.py covering added functionalities (to test JavaScript code dummy.js was added to the root of Pylama)
    • fixed failing tests on Win platform, by adding platform check and platform depended errors to ignore,
    • extended README by gjslint entries,
    • extended requirements section in README by python-gflags and curses for Win platform users (after issues when running on clean Python 2.7 virtualenv).

    Attention:

    • no Python 3 support for gjslint due to issues like: usage of StringIO in closure_linter/tesutil.py etc.

    Requirements:

    • python-gflags
      • Linux: sudo apt-get install python-gflags and verify installation using: dpkg -s python-gflags
      • Windows: pip install python-gflags and verify installation using: pip freeze

    Tests:

    • Installing Pylama with integrated Closure-Linter checker by python setup.py install ended successfully.
    • New solution was successfully tested (unittests + end-user tests) on Win (v.7) and Unix/Linux (Ubuntu).

    Notes:

    • No modifications besides removal of printing utilities were done to Closure-Linter code. Printing utilities were removed due to common printing interface provided by Pylama.

    Usage:

    • pylama.exe --linters=gjslint --ignore=E:0010 --report=report.txt E:\path\to\dir_or_file
    • If Python and JavaScript linters are used at the same time, but in defined directory there is just JavaScript code or just Python code, then just this linter will be used for which the code was found. Example: If in E:\bootstrap\js there are just *.js files. Usage: pylama.exe --linters=pep8,gjslinter E:\bootstrap\js will use just gjslinter. It works exactly the same the other way round.
  • Fix parsing of multi-options for pycodestyle

    Fix parsing of multi-options for pycodestyle

    This correctly parses options of the form "E302,W405", which before this was split into individual characters. This resulted in all errors and/or being considered when ignoring/selecting.

    Since specifying just "E" disables all errors, having a list of characters meant that it always encountered an individual "E" and thus disabled all errors.

  • Rename async to async_mode for python 3.7 compatibility

    Rename async to async_mode for python 3.7 compatibility

    This PR should not break backwards compatibility for anyone using pylama as a command line tool. It is however breaking for anyone importing from pylama.async or relying on the existence of options.async.

    Fixes klen/pylama#89

    This PR is based on PR #112 by @maxnordlund and includes his commits.

  • Absolute file path for output

    Absolute file path for output

    Feature Request: Can you provide an option to output the absolute file path of the files?

    Problem: We use PyCharm for the python development. There you can run external tools like pylama. In the settings you can add a filter for the filepath, linenumber and column. This create clickable links to the files in the output of the external tools. Unfortunately this works only if the filepath is absolute.

    Is it possible to add this option?

  • Exclude/Ignore is not working

    Exclude/Ignore is not working

    Maybe the style is being passed wrong to pycodestyle.

    How to reproduce

    1. In tox.ini create:
    [pycodestyle]
    exclude = .tox
    
    1. Run tox and pylama try to test everything inside .tox, example:
    pylama -v --options=tox.ini
    
    File is reading: .tox/py36-test/bin/rst2odt.py
    Run pycodestyle {'ignore': ['E501', 'C0301'], 'exclude': ['.tox', '.env', '.venv', '.git', 'build', 'dist', 'docs', 'tests', 'ui', '*.egg-info', '*cache*'], 'max-line-length': 100, 'statistics': ('T', 'r', 'u', 'e'), 'count': ('T', 'r', 'u', 'e')}
    
    1. Using the same configuration file, from tox.ini, but directly with pycodestyle:
    pycodestyle --config=tox.ini -v
    
    cli configuration: tox.ini
    directory .
    checking ./setup.py
    directory ./helpdev
    checking ./helpdev/__init__.py
    checking ./helpdev/__main__.py
    directory ./examples
    directory ./.vscode
    
    1. Executing passing a list insteady of a string seems to result the same as the problem with pylama:

    pycodestyle --exclude=['.tox'] -vv

    Maybe something related to #143, but for me, it does not match the description. Tks

    Info about the environment:

    * HARDWARE-----------------------------------------------------------------------
        - Machine....................... x86_64
        - Processor..................... Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
        - Total Memory.................. 16689 MB
        - Free Memory................... 2166 MB
        - Total Swap.................... 19999 MB
        - Free Swap..................... 19999 MB
    * OPERATING SYSTEM---------------------------------------------------------------
        - System........................ Linux
        - Release....................... 4.15.0-48-generic
        - Platform...................... Linux-4.15.0-48-generic-x86_64-with-debian-buster-sid
        - Version....................... #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019
    * THREADS------------------------------------------------------------------------
        - Version....................... NPTL 2.27
        - Name.......................... pthread
        - Lock.......................... semaphore
    * PYTHON DISTRIBUTION------------------------------------------------------------
        - Version....................... 3.6.8
        - C Compiler.................... GCC 7.3.0
        - C API Version................. 1013
        - Implementation................ cpython
        - Implementation Version........ 3.6.8
    * PYTHON PACKAGES----------------------------------------------------------------
        - pycodestyle................... 2.5.0
        - pylama........................ 7.7.1
        - tox........................... 3.9.0
    

    Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

  • settings overwriting eachother

    settings overwriting eachother

    I have the following lines in my pylama.ini file [pylama:*/init.py] ignore = W0611

    [pylama:bla/init.py] ignore = E402,W0611

    On one machine this works as expected (W0611 is ignored for all init.py files, while bla/init.py also ignores E402). But when the same code is checked on a different machine, with the same pylama version, it causes E402 errors to be found for bla/init.py.

  • Specify line length for all linters.

    Specify line length for all linters.

    I would like to set my line length to 120 as opposed to 79.

    It seems that pylama has no global option to specify line length config. When running pep8 it is ignoring the global pep8 config file.

  • mccabe cannot be configured

    mccabe cannot be configured

    There is no documentation on how to setup mccabe when using pylama. Anyone would expect something like the following inside setup.cfg:

    [pylama:mccabe]
    max-complexity = 15
    

    But on adding this I still get the error (obfuscated):

    scrapers/***/scraper.py:62:1: C901 '***' is too complex (12) [mccabe]
    

    I assume the default is 10 due to this, but the override is not being picked up.


    Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

  • Clarify license for Debian packaging

    Clarify license for Debian packaging

    Currently I am working on creating Debian package for pylama (https://bugs.debian.org/779449). However, the content of pylama/__init__.py is confused. The comment string says it is BSD license, but the LICENSE file is LGPL-3+.

        """
    Code audit tool for python.
    :copyright: 2013 by Kirill Klenov.
    :license: BSD, see LICENSE for more details.
    """
    
    __version__ = "7.0.9"
    __project__ = "pylama"
    __author__ = "Kirill Klenov <[email protected]>"
    __license__ = "GNU LGPL"
    

    Please help to clarify the actual license of this package by removing other license name/text in pylama so that we can work on Debian packaging, thanks.

    --- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/34617584-clarify-license-for-debian-packaging?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github).
  • [WIP] setup.py: install_requires: remove versions

    [WIP] setup.py: install_requires: remove versions

    I am trying to install pylama system-wide on Arch Linux, which has pyflakes 1.1.0 already, and running pylama fails with:

    pkg_resources.ContextualVersionConflict: (pyflakes 1.1.0 (/usr/lib/python3.5/site-packages), Requirement.parse('pyflakes==1.0.0'), {'pylama'})

    pkg_resources.DistributionNotFound: The 'pyflakes==1.0.0' distribution was not found and is required by pylama

    This commit fixes it by only using the package name from requirements.txt, but not the version.

    Alternatively I could imagine replacing the '==' with '>=' to ensure the minimum requirements are met, which is probably better?!

    On the other hand this might not be useful altogether, and instead tools like pipsi or virtualenvs should be used for pylama only?!

  • pylint linter is ignored when pylama is run under pytest

    pylint linter is ignored when pylama is run under pytest

    i have this in tox.ini

    [pytest]
    norecursedirs = build .* .env media static deployment
    addopts = -vvl --pylama
    DJANGO_SETTINGS_MODULE=pdt.settings_test
    
    [pylama]
    format = pep8
    skip = */.tox/*,*/.env/*,pdt/core/migrations/*
    linters = pylint,mccabe,pep8,pep257
    ignore = F0401,C0111,E731,D100
    
    [pylama:pep8]
    max_line_length = 120
    

    when i run tests:

    ─[0] <git:(master 3b9152f✱✈) > py.test tests
    =============================================================================================== test session starts ===============================================================================================
    platform linux -- Python 3.4.0 -- py-1.4.26 -- pytest-2.7.0 -- /home/vagrant/workspace/pdt/.env/bin/python3
    cachedir: /home/vagrant/workspace/pdt/.cache
    rootdir: /home/vagrant/workspace/pdt, inifile: tox.ini
    plugins: pep257, cache, pep8, django, pylama, cov
    collected 7 items 
    
    tests/__init__.py SKIPPED
    tests/conftest.py SKIPPED
    tests/api/__init__.py SKIPPED
    tests/api/test_api.py SKIPPED
    tests/api/test_api.py::test_migration_filter_exclude_status PASSED
    tests/api/test_api.py::test_migration_filter_status PASSED
    tests/api/test_api.py::test_migration_filter_ci_project PASSED
    
    ======================================================================================= 3 passed, 4 skipped in 0.85 seconds =======================================================================================
    
    

    but when i run pylama separately:

    └─[0] <git:(master 3b9152f✱) > pylama tests                
    tests/conftest.py:19:23: W0622 Redefining built-in 'type' [pylint]
    tests/conftest.py:51:19: W0621 Redefining name 'ci_project_name' from outer scope (line 39) [pylint]
    tests/conftest.py:51:36: W0621 Redefining name 'ci_project_description' from outer scope (line 45) [pylint]
    tests/conftest.py:69:50: W0621 Redefining name 'ci_project' from outer scope (line 51) [pylint]
    tests/conftest.py:69:13: W0621 Redefining name 'instance_name' from outer scope (line 57) [pylint]
    tests/conftest.py:69:28: W0621 Redefining name 'instance_description' from outer scope (line 63) [pylint]
    tests/conftest.py:71:0: C0301 Line too long (111/100) [pylint]
    tests/conftest.py:87:12: W0621 Redefining name 'release_name' from outer scope (line 75) [pylint]
    tests/conftest.py:87:26: W0621 Redefining name 'release_date' from outer scope (line 81) [pylint]
    tests/conftest.py:111:9: W0621 Redefining name 'case_id' from outer scope (line 93) [pylint]
    tests/conftest.py:111:48: W0621 Redefining name 'ci_project' from outer scope (line 51) [pylint]
    tests/conftest.py:111:30: W0621 Redefining name 'case_description' from outer scope (line 105) [pylint]
    tests/conftest.py:111:18: W0621 Redefining name 'case_title' from outer scope (line 99) [pylint]
    tests/conftest.py:111:60: W0621 Redefining name 'release' from outer scope (line 87) [pylint]
    tests/conftest.py:114:0: C0301 Line too long (107/100) [pylint]
    tests/conftest.py:121:28: W0108 Lambda may not be necessary [pylint]
    tests/conftest.py:144:27: W0108 Lambda may not be necessary [pylint]
    tests/conftest.py:156:28: W0108 Lambda may not be necessary [pylint]
    tests/conftest.py:166:28: W0108 Lambda may not be necessary [pylint]
    tests/api/test_api.py:31:0: C0330 Wrong hanging indentation.             'id': mr2.id,             ^   | [pylint]
    tests/api/test_api.py:32:0: C0330 Wrong hanging indentation.             'ci_project': migration.case.ci_project.name,             ^   | [pylint]
    tests/api/test_api.py:33:0: C0330 Wrong hanging indentation.             'instance': mr2.instance.name,             ^   | [pylint]
    tests/api/test_api.py:34:0: C0330 Wrong hanging indentation.             'status': mr2.status,             ^   | [pylint]
    tests/api/test_api.py:35:0: C0330 Wrong hanging indentation.             'datetime': equals_any,             ^   | [pylint]
    tests/api/test_api.py:36:0: C0330 Wrong hanging indentation.             'log': mr2.log},             ^   | [pylint]
    tests/api/test_api.py:37:0: C0330 Wrong continued indentation.         ]         ^                    | [pylint]
    
    

  • Use tomli/tomllib instead of the unmaintained toml package

    Use tomli/tomllib instead of the unmaintained toml package

    Replace the use of the unmaintained toml package with the modern alternatives: the built-in tomllib in Python 3.11+, and its equivalent tomli in older Python versions. tomli installs type stubs, so there is no need for an additional types-* package for it.

  • Docs: Add section about configuring `pre-commit`

    Docs: Add section about configuring `pre-commit`

    Currently one cannot even find the information that pylama defines a pre-commit hook. I think a section about setting this up would be userfriendly, also regarding #229.

  • feat: extract todos

    feat: extract todos

    should a code audit tool have the ability to extract TODO comments from the code?

    i sure think so!

    let me know if y'all are open to a PR. I'm imagining single-line support only atm. If the config file specifies tool.pylama.todo-file then we will by default collect text after TODO: and dup those lines log-style plaintext into the destination file.

    could later be generalized to comment extraction of non-todo comments but meh for now nah

  • 8.3.8: Support for pylint>=2.13.0

    8.3.8: Support for pylint>=2.13.0

    Context

    Python version == 3.8.2 Pylama version == 8.3.8 Pylint version >= 2.13.0

    Problem

    From the Pylint changelog:

    When run in parallel mode pylint now pickles the data passed to subprocesses with the dill package. The dill package has therefore been added as a dependency.

    Pylint fails to pickle pylint.lint.pylinter.PyLinter.reporter, which is a pylama Reporter object:

    Traceback (most recent call last):
      File "/Users/*/.local/share/virtualenvs/*/bin/pylama", line 8, in <module>
        sys.exit(shell())
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/pylama/main.py", line 115, in shell
        errors = check_paths(
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/pylama/main.py", line 68, in check_paths
        errors += run(path=path, code=code, rootdir=rootdir, options=options)
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/pylama/core.py", line 36, in run
        linter.run_check(ctx)
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/pylama/lint/pylama_pylint.py", line 69, in run_check
        Run([ctx.temp_filename] + args, reporter=reporter, exit=False)
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/pylint/lint/run.py", line 358, in __init__
        linter.check(args)
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1077, in check
        check_parallel(
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/pylint/lint/parallel.py", line 149, in check_parallel
        jobs, initializer=initializer, initargs=[dill.dumps(linter)]
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/dill/_dill.py", line 304, in dumps
        dump(obj, file, protocol, byref, fmode, recurse, **kwds)#, strictio)
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/dill/_dill.py", line 276, in dump
        Pickler(file, protocol, **_kwds).dump(obj)
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/dill/_dill.py", line 498, in dump
        StockPickler.dump(self, obj)
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 485, in dump
        self.save(obj)
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 601, in save
        self.save_reduce(obj=obj, *rv)
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 715, in save_reduce
        save(state)
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 558, in save
        f(self, obj)  # Call unbound method with explicit self
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/dill/_dill.py", line 990, in save_module_dict
        StockPickler.save_dict(pickler, obj)
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 969, in save_dict
        self._batch_setitems(obj.items())
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 995, in _batch_setitems
        save(v)
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 601, in save
        self.save_reduce(obj=obj, *rv)
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 685, in save_reduce
        save(cls)
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 558, in save
        f(self, obj)  # Call unbound method with explicit self
      File "/Users/*/.local/share/virtualenvs/*/lib/python3.8/site-packages/dill/_dill.py", line 1440, in save_type
        StockPickler.save_global(pickler, obj, name=name)
      File "/Users/*/.pyenv/versions/3.8.2/lib/python3.8/pickle.py", line 1068, in save_global
        raise PicklingError(
    _pickle.PicklingError: Can't pickle <class 'pylama.lint.pylama_pylint.Linter.run_check.<locals>.Reporter'>: it's not found as pylama.lint.pylama_pylint.Linter.run_check.<locals>.Reporter
    

    Suggestions

    • Moving Reporter from Linter.run_check to Linter will resolve the problem.
    • Pinning pylint<=2.12.2 for the time being.
  • is there just a place where I can just download the files I need?

    is there just a place where I can just download the files I need?

    i cant install pip or python (but I have atom so I can just use it there). is there any way I can just like install the files as a zip directly from here or some other website?

  • 8.3.8: pytest is failing in `tests/test_linters.py::test_quotes` unit

    8.3.8: pytest is failing in `tests/test_linters.py::test_quotes` unit

    I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

    • python3 -sBm build -w --no-isolation
    • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
    • install .whl file in </install/prefix>
    • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

    Here is pytest output:

    + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pylama-8.3.8-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pylama-8.3.8-2.fc35.x86_64/usr/lib/python3.8/site-packages
    + /usr/bin/pytest -ra -q
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
    rootdir: /home/tkloczko/rpmbuild/BUILD/pylama-8.3.8, configfile: setup.cfg
    plugins: pylama-8.3.8
    collected 33 items
    
    tests/test_config.py ...
    tests/test_context.py ......
    tests/test_core.py .....
    tests/test_linters.py .........F
    
    ================================================================================= FAILURES =================================================================================
    _______________________________________________________________________________ test_quotes ________________________________________________________________________________
    
    source = '#!/usr/bin/env python\n# coding: utf-8\n# (c) 2005 Divmod, Inc.  See LICENSE file for details\n\n\n# commented code\n...e expected\'\n\n    def bad_method(self):  # type: () -> None\n        """Return type mismatch."""\n        return 1\n'
    
        def test_quotes(source):
            from pylama.lint import LINTERS, Linter
    
    >       quotes = LINTERS["quotes"]
    E       KeyError: 'quotes'
    
    tests/test_linters.py:198: KeyError
    ========================================================================= short test summary info ==========================================================================
    FAILED tests/test_linters.py::test_quotes - KeyError: 'quotes'
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ======================================================================= 1 failed, 23 passed in 4.97s =======================================================================
    
Related tags
Metrinome is an all-purpose tool for working with code complexity metrics.
Metrinome is an all-purpose tool for working with code complexity metrics.

Overview Metrinome is an all-purpose tool for working with code complexity metrics. It can be used as both a REPL and API, and includes: Converters to

Dec 26, 2022
CodeAnalysis - Static Code Analysis: a code comprehensive analysis platform
CodeAnalysis - Static Code Analysis: a code comprehensive analysis platform

TCA, Tencent Cloud Code Analysis English | 简体中文 What is TCA Tencent Cloud Code A

Jan 7, 2023
A static analysis tool for Python

pyanalyze Pyanalyze is a tool for programmatically detecting common mistakes in Python code, such as references to undefined variables and some catego

Jan 7, 2023
TidyPy is a tool that encapsulates a number of other static analysis tools and makes it easy to configure, execute, and review their results.

TidyPy Contents Overview Features Usage Docker Configuration Ignoring Issues Included Tools Included Reporters Included Integrations Extending TidyPy

Nov 27, 2022
Alarmer is a tool focus on error reporting for your application.

alarmer Alarmer is a tool focus on error reporting for your application. Installation pip install alarmer Usage It's simple to integrate alarmer in yo

Jul 3, 2022
Pymwp is a tool for automatically performing static analysis on programs written in C

pymwp: MWP analysis in Python pymwp is a tool for automatically performing static analysis on programs written in C, inspired by "A Flow Calculus of m

Dec 2, 2022
Turn your Python and Javascript code into DOT flowcharts
Turn your Python and Javascript code into DOT flowcharts

Notes from 2017 This is an older project which I am no longer working on. It was built before ES6 existed and before Python 3 had much usage. While it

Jan 9, 2023
Find dead Python code

Vulture - Find dead code Vulture finds unused code in Python programs. This is useful for cleaning up and finding errors in large code bases. If you r

Jan 3, 2023
The uncompromising Python code formatter
The uncompromising Python code formatter

The Uncompromising Code Formatter “Any color you like.” Black is the uncompromising Python code formatter. By using it, you agree to cede control over

Dec 28, 2022
A static type analyzer for Python code

pytype - ? ✔ Pytype checks and infers types for your Python code - without requiring type annotations. Pytype can: Lint plain Python code, flagging c

Dec 31, 2022
Print a directory tree structure in your Python code.

directory-structure Print a directory tree structure in your Python code. Download You can simply: pip install directory-structure Or you can also: Cl

Dec 19, 2022
Python package to parse and generate C/C++ code as context aware preprocessor.

Devana Devana is a python tool that make it easy to parsing, format, transform and generate C++ (or C) code. This tool uses libclang to parse the code

Dec 28, 2022
Find usage statistics (imports, function calls, attribute access) for Python code-bases

Python Library stats This is a small library that allows you to query some useful statistics for Python code-bases. We currently report library import

May 2, 2022
A very minimalistic python module that lets you track the time your code snippets take to run.

Clock Keeper A very minimalistic python module that lets you track the time your code snippets take to run. This package is available on PyPI! Run the

Jan 19, 2022
This is a Python program to get the source lines of code (SLOC) count for a given GitHub repository.

This is a Python program to get the source lines of code (SLOC) count for a given GitHub repository.

Mar 10, 2022
coala provides a unified command-line interface for linting and fixing all your code, regardless of the programming languages you use.

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." ― John F. Woods coala provides a

Jan 2, 2023
Guesslang detects the programming language of a given source code
Guesslang detects the programming language of a given source code

Detect the programming language of a source code

Dec 29, 2022
Learning source code review, spot vulnerability, find some ways how to fix it.

Learn Source Code Review Learning source code review, spot vulnerability, find some ways how to fix it. WordPress Plugin Authenticated Stored XSS on C

Dec 31, 2022
An app to show the total number of lines of code written by an user.

Lines of code Have you ever wondered how many lines of code you wrote in github? This tool will calculate it for you! To calculate the total number of

Jan 26, 2022