@codacy/tools-pylint-4

中文文档
0.28.0发布于 2026/11/09MITTypeScriptCommonJS近 30 天下载 1.2万

Pylint adapter — CLI-mode Python linter

原始使用文档
文档目录6 节
  1. Table of Contents
  2. Overview
  3. Updating patterns
  4. Updating the Pylint version
  5. Development
  6. Notes for maintainers

@codacy/tools-pylint-4

Table of Contents


Overview

Python static analyzer using the Pylint binary. Uses the CLI execution strategy — installs pylint into a dedicated venv, spawns it via spawnTool(), and parses its JSON2 output.

PropertyValue
Tool IDPyLintPython3
Codacy UUID31677b6d-4ae0-4f56-8041-606a8d7a8e61
StrategyCLI
LanguagesPython
Binarypylint
File patterns**/*.py
Pattern count~340
PrerequisitesPython 3.10+

Updating patterns

# Re-fetch pattern metadata from the Codacy API
pnpm prefetch

# Commit the result
git add src/patterns.json

Pattern IDs follow the format PyLintPython3_C0114, PyLintPython3_E0602, etc.

Updating the Pylint version

  1. Update PREFERRED_VERSION and the pylint==X.Y.Z entry in PIP_PACKAGES in src/adapter.ts
  2. Run pnpm prefetch to check for new/removed rules
  3. Run pnpm test to verify compatibility
  4. If the major version changes, create a new adapter package (pylint-4/)

Development

pnpm build    # Build with tsup
pnpm test     # Run tests (requires pylint in PATH or auto-installed)

Install pylint manually for local development:

pip install pylint

Or let the adapter auto-install into a venv:

codacy-analysis analyze . --install-dependencies

The adapter installs these packages into the venv:

  • pylint==4.0.8
  • pylint-django
  • pylint-flask
  • pylint-celery
  • pylint-common
  • pylint-beam
  • pylint-pytest
  • SaltPyLint

Notes for maintainers

  • JSON2 output format: The adapter uses --output-format=json2 which outputs { "messages": [...], "statistics": {...} }. This is the modern format (Pylint 3.x+).
  • 0-based columns: Pylint reports columns as 0-based. The adapter adds 1 to convert to the 1-based model used by Codacy.
  • Nullable endLine/endColumn: These fields can be null in Pylint output. The adapter omits them from Issue objects when null.
  • Exit code bitmask: Pylint uses a bitmask exit code. Bit 5 (value 32) indicates a usage error (bad config/args). Bits 0-4 (values 1-31) indicate normal findings. The adapter checks exitCode & 32 to distinguish errors from normal findings.
  • E0401 filtering: The E0401 (import-error) pattern is permanently filtered because sandboxed environments cannot resolve third-party imports. This matches the existing Codacy wrapper behavior.
  • Plugin support: The adapter bundles the same plugins as the Codacy wrapper (pylint-django, pylint-flask, pylint-celery, pylint-common, pylint-beam, pylint-pytest, SaltPyLint).
  • Pattern parameters: Some patterns accept parameters (e.g. max-line-length for C0301, max-locals for R0914). These are passed as --{param}={value} CLI arguments.
  • Python 3.10+: pylint 4 dropped 3.9, so install passes >=3.10.0 to ensurePython (an older system Python, e.g. Apple's 3.9 /usr/bin/python3, is skipped and a portable 3.12 is downloaded) and to ensureVenv (a venv an earlier install built on 3.9 is rebuilt, not reused).
  • Venv isolation: Pylint and its plugins are installed in a dedicated venv at ~/.codacy/runtimes/PyLintPython3/venv/ to avoid dependency conflicts with other Python tools. The path is keyed on the stable tool ID rather than the package folder name, so a major bump keeps the venv and upgrades it in place instead of orphaning it.
  • Config files: The adapter reports pylintrc or .pylintrc (in that order) as a local configuration file, and nothing else. Codacy Cloud accepts only those two names, so pyproject.toml, setup.cfg, tox.ini and pylintrc.toml never count, even with a Pylint section. Pylint still reads them at run time for its other settings.

版本与发布记录

@codacy/tools-pylint-4 共发布 9 个版本,首次发布于 2026/09/02;过去 12 个月发布了 9 个版本。

版本发布日期距今
0.28.0latest2026/11/09今天
0.27.12026/11/054 天前
0.27.02026/11/036 天前
0.26.02026/10/3010 天前
0.25.02026/10/1921 天前
0.24.02026/09/251 个月前

关于 @codacy/tools-pylint-4 的常见问题

@codacy/tools-pylint-4 是什么?

Pylint adapter — CLI-mode Python linter

如何安装 @codacy/tools-pylint-4?

在项目目录运行 npm install @codacy/tools-pylint-4,或使用 pnpm add / yarn add / bun add。

@codacy/tools-pylint-4 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codacy/tools-pylint-4 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@codacy/tools-pylint-4 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codacy/tools-pylint-4 可以商用吗?

@codacy/tools-pylint-4 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codacy/tools-pylint-4 的下载量有多少?

根据 npm 官方下载统计,@codacy/tools-pylint-4 在 2026/10/10 – 2026/11/08 这 30 天内被下载 11,709 次,日均约 390 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codacy/tools-pylint-4 还在维护吗?

最新版本 0.28.0 发布于 2026/11/09(今天);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/09/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。