{"id":8491,"library":"pylama","title":"Pylama","description":"Pylama is a comprehensive code audit tool for Python. It acts as a wrapper, integrating various popular linters and checkers such as pycodestyle, pydocstyle, PyFlakes, Mccabe, Pylint, Radon, Mypy, and Vulture, to provide a unified interface for checking code quality. The current version is 8.4.1, and it receives updates periodically to support newer Python versions and linter functionalities.","status":"active","version":"8.4.1","language":"en","source_language":"en","source_url":"https://github.com/klen/pylama","tags":["linter","code quality","static analysis","python","audit"],"install":[{"cmd":"pip install pylama","lang":"bash","label":"Basic Installation"},{"cmd":"pip install pylama[toml]","lang":"bash","label":"With TOML configuration support"},{"cmd":"pip install pylama[mypy]","lang":"bash","label":"With Mypy linter support"},{"cmd":"pip install pylama pylint","lang":"bash","label":"With Pylint (requires separate install)"}],"dependencies":[{"reason":"Core linter wrapped by Pylama","package":"pycodestyle","optional":true},{"reason":"Core linter wrapped by Pylama","package":"pydocstyle","optional":true},{"reason":"Core linter wrapped by Pylama","package":"pyflakes","optional":true},{"reason":"Core linter wrapped by Pylama","package":"mccabe","optional":true},{"reason":"Popular linter wrapped by Pylama; often requires separate installation for full functionality.","package":"pylint","optional":true},{"reason":"Code complexity checker wrapped by Pylama","package":"radon","optional":true},{"reason":"Optional static type checker wrapped by Pylama, installed via `pylama[mypy]`","package":"mypy","optional":true},{"reason":"Dead code checker wrapped by Pylama","package":"vulture","optional":true}],"imports":[{"symbol":"check_path","correct":"from pylama.main import check_path"},{"symbol":"parse_options","correct":"from pylama.main import parse_options"},{"note":"Used for writing custom linters.","symbol":"Linter","correct":"from pylama.lint import Linter"}],"quickstart":{"code":"import os\nimport textwrap\nfrom pylama.main import check_path, parse_options\n\n# Create a dummy Python file to check\nfile_content = textwrap.dedent('''\n    import os, sys\n\n    def my_function():\n        x=10 # E225 missing whitespace around operator\n        if x > 5:\n            print(\"Hello\")\n        return \"world\"\n\n    my_function() # W0612 unused variable 'x'\n''')\n\nfile_path = \"./temp_pylama_test.py\"\nwith open(file_path, \"w\") as f:\n    f.write(file_content)\n\n# Run pylama programmatically\n# Options can be passed as a dictionary\noptions_dict = {\n    'linters': ['pycodestyle', 'pyflakes'], # Specify linters to use\n    'ignore': ['W0611'], # Ignore specific warnings, e.g., unused imports\n    'select': []\n}\n\n# parse_options processes paths and dictionary options into an options object\noptions = parse_options([file_path], **options_dict)\nerrors = check_path(options)\n\nif errors:\n    print(f\"Found {len(errors)} issues in {file_path}:\")\n    for error in errors:\n        print(f\"  {error.filename}:{error.lnum}:{error.col} [{error.type}] {error.text} [{error.linter}]\")\nelse:\n    print(f\"No issues found in {file_path}.\")\n\n# Clean up the dummy file\nos.remove(file_path)\n","lang":"python","description":"The primary way to use Pylama is via the command line, running `pylama` in your project's root or specifying files/directories. For programmatic use, you can import `check_path` and `parse_options` from `pylama.main` to analyze files and retrieve issues directly within Python code. This example demonstrates creating a temporary file with known issues, running `pylama` on it, and printing the reported errors."},"warnings":[{"fix":"Upgrade your Python environment to 3.7+ or pin Pylama to version <=7.7.1 for Python 2.x projects.","message":"Pylama dropped support for Python 2.x. It now requires Python 3.7 or newer. Older Python versions need Pylama 7.7.1 or earlier.","severity":"breaking","affected_versions":">=8.0.5"},{"fix":"Ensure you are only passing Python files to Pylama, or consider alternative tools for non-Python file auditing.","message":"The `--force` option, which allowed Pylama to check non-Python files, was removed. By default, Pylama now only checks Python files.","severity":"breaking","affected_versions":">=8.1.4"},{"fix":"Update your Pylama configuration (e.g., `pylama.ini`) to use `max-complexity` instead of `complexity` for mccabe settings.","message":"When using the 'mccabe' linter, the argument for complexity was renamed from `complexity` to `max-complexity`.","severity":"gotcha","affected_versions":">=8.1.4"},{"fix":"Ensure you are using a compatible version of Pylint (e.g., Pylint >= 2.8.1) or explicitly install `pylama_pylint` if available for better integration.","message":"Pylama's integration with Pylint can be sensitive to Pylint's internal changes. Specifically, Pylint 2.8.0 temporarily removed `__pkginfo__.numversion`, causing issues with Pylama. While `numversion` was temporarily re-added in Pylint 2.8.1, ensure compatibility.","severity":"gotcha","affected_versions":"Pylama versions using Pylint <= 2.8.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install Pylint alongside Pylama: `pip install pylama pylint` or `pip install pylama_pylint` if a dedicated integration package is preferred/required.","cause":"The Pylint linter, while wrapped by Pylama, is not installed by default and needs to be installed separately or via the `pylama_pylint` module for Pylama to use it.","error":"Pylint doesn't exist"},{"fix":"Enable `isort` in your Pylama configuration file (`pylama.ini`) by adding `linters = isort` or specifying it on the command line: `pylama --linters=isort <path>`.","cause":"The `isort` linter is available through Pylama but is not enabled by default. If `isort` is installed and you expect Pylama to report on import sorting, it needs to be explicitly configured.","error":"Incorrectly sorted imports. [isort]"},{"fix":"Check the documentation for your IDE's Python extension for Pylama output parsing configurations. Sometimes, updating the extension or using a specific output format for Pylama (e.g., `--format pep8` or `--format pylint`) might resolve the issue.","cause":"This often occurs when using Pylama with IDE extensions (like in VS Code) where the parsing of Pylama's aggregated output for specific linters (like Mypy) is not correctly mapped to the IDE's 'Problems' panel.","error":"mypy output is visible in the \"Output tab\", but not in the \"Problems\" tab."},{"fix":"Verify that all paths specified in Pylama commands or configuration files (`pylama.ini`, `setup.cfg`, etc.) are correct and accessible from where Pylama is being executed. Use absolute paths if there's ambiguity with relative paths.","cause":"This typically happens when Pylama is configured to check a path that does not exist or is inaccessible in the current environment, often due to incorrect relative paths in configuration files or CI/CD pipelines.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'some/path/file.py'"}]}