{"id":4368,"library":"lintrunner-adapters","title":"Lintrunner Adapters","description":"Lintrunner Adapters provides a collection of wrappers and tools that integrate various linters (like Black, Ruff, Pylint, Bandit, etc.) with the `lintrunner` framework. It enables unified linting across a project using a single configuration. The current version is 0.13.0, and releases are frequent, primarily adding new linter adapters or fixing issues with existing ones.","status":"active","version":"0.13.0","language":"en","source_language":"en","source_url":"https://github.com/justinchuby/lintrunner-adapters","tags":["linting","code quality","tooling","adapters","lintrunner","ruff","black","pylint"],"install":[{"cmd":"pip install lintrunner-adapters","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This library provides adapters for the lintrunner framework itself.","package":"lintrunner","optional":false},{"reason":"Required if you plan to use the Black linter adapter. Each adapter depends on its respective linter.","package":"black","optional":true},{"reason":"Required if you plan to use the Ruff linter adapter. Each adapter depends on its respective linter.","package":"ruff","optional":true},{"reason":"Required if you plan to use the Pylint linter adapter. Each adapter depends on its respective linter.","package":"pylint","optional":true},{"reason":"Required if you plan to use the Bandit linter adapter. Each adapter depends on its respective linter.","package":"bandit","optional":true},{"reason":"Required if you plan to use the Docformatter linter adapter. Each adapter depends on its respective linter.","package":"docformatter","optional":true}],"imports":[{"note":"Lintrunner adapters are typically referenced as strings in a `lintrunner.toml` configuration file (e.g., `linter_class = \"lintrunner_adapters.ruff_linter:RuffLinter\"`) rather than directly imported into user Python code. This `from ... import ...` demonstrates how `lintrunner` internally loads the adapter class.","symbol":"RuffLinter","correct":"from lintrunner_adapters.ruff_linter import RuffLinter"},{"note":"Lintrunner adapters are typically referenced as strings in a `lintrunner.toml` configuration file (e.g., `linter_class = \"lintrunner_adapters.black_linter:BlackLinter\"`) rather than directly imported into user Python code. This `from ... import ...` demonstrates how `lintrunner` internally loads the adapter class.","symbol":"BlackLinter","correct":"from lintrunner_adapters.black_linter import BlackLinter"}],"quickstart":{"code":"import os\n\n# 1. Create a sample Python file to lint\npython_code = \"\"\"def foo ( x ):\\n  return x+1\\n\"\"\"\nwith open(\"test_file.py\", \"w\") as f:\n    f.write(python_code)\n\n# 2. Create a lintrunner.toml configuration (simulating user setup)\n# In a real project, this would be a file named `lintrunner.toml`\nlintrunner_toml_content = \"\"\"\n[linter.ruff]\nlinter_class = \"lintrunner_adapters.ruff_linter:RuffLinter\"\n\n[linter.black]\nlinter_class = \"lintrunner_adapters.black_linter:BlackLinter\"\nargs = [\"--check\", \"--diff\"]\n\"\"\"\nwith open(\"lintrunner.toml\", \"w\") as f:\n    f.write(lintrunner_toml_content)\n\n# 3. Ensure lintrunner and the linters are installed for this example to run\n# In a real setup, `pip install lintrunner ruff black` would be done.\n# We can't actually run lintrunner directly in this snippet, but demonstrate setup.\nprint(\"Created test_file.py and lintrunner.toml. To run, execute:\")\nprint(\"pip install lintrunner ruff black\")\nprint(\"lintrunner --config lintrunner.toml test_file.py\")\n\n# Clean up (optional, for standalone execution)\n# os.remove(\"test_file.py\")\n# os.remove(\"lintrunner.toml\")","lang":"python","description":"This quickstart demonstrates how to configure `lintrunner` to use adapters from `lintrunner-adapters`. You define linters in a `lintrunner.toml` file, specifying the `linter_class` as a string path to the adapter. You must install `lintrunner` and the underlying linters (e.g., `ruff`, `black`) separately. The example creates a `test_file.py` and `lintrunner.toml` locally, and then provides instructions on how to execute `lintrunner` to apply the configured linters."},"warnings":[{"fix":"Ensure all linters referenced in your `lintrunner.toml` are installed in your environment (e.g., `pip install ruff black pylint`).","message":"The `lintrunner-adapters` library itself does not install the underlying linters (e.g., `ruff`, `black`, `pylint`). You must explicitly install each linter that you intend to use via its respective adapter.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Keep `lintrunner-adapters` updated to the latest version to ensure compatibility with recent linter releases. Check release notes for specific compatibility information.","message":"Breaking changes in underlying linters (e.g., `ruff`, `black`) can cause adapters to behave unexpectedly or fail. `lintrunner-adapters` updates are typically released to maintain compatibility with new linter versions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update any scripts or CI configurations that use the `PylintLinter` to handle explicit errors rather than assuming silent failure. Inspect Pylint output for issues.","message":"The `PylintLinter` adapter changed its behavior to raise an error when Pylint fails, instead of failing silently. Scripts or CI pipelines that relied on silent failures might break.","severity":"breaking","affected_versions":">=0.12.2"},{"fix":"Ensure your environment is using Python 3.9 or a newer version (e.g., `python3.9 -m pip install lintrunner-adapters`).","message":"This library requires Python 3.9 or newer. Running with older Python versions will result in installation or runtime errors.","severity":"gotcha","affected_versions":"<0.12.0 (but >=0.12.0 explicitly requires it)"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}