Skip to main content

Extensible Python linter written in Rust

Project description

jg-lint

Extensible Python linter with a Rust core.

Installation

Requires Python 3.14+.

uv add jg-lint

or with pip:

pip install jg-lint

or with Poetry:

poetry add jg-lint

Development install

To build from source, you need Maturin and a Rust toolchain:

git clone https://github.com/giacosoft/jg-lint.git
cd jg-lint
uv sync
uv run maturin develop

Usage

jg-lint check <paths...>

Lint one or more files or directories:

jg-lint check src/
jg-lint check src/ lib/ main.py
jg-lint check --config path/to/project src/

The --config flag points to the directory containing pyproject.toml (defaults to .).

Output looks like:

src/app.py:12:1: MY001 TODO comments should be tracked as issues
src/app.py:45:1: MY001 TODO comments should be tracked as issues

Found 2 violation(s)

Exit code is 1 if any violations are found, 0 otherwise.

Inline suppression

Suppress specific rules on a line with # noqa:

x = something()  # noqa: MY001
y = another()  # noqa: MY001, MY002

Configuration

All configuration lives in pyproject.toml under [tool.jg-lint]:

[tool.jg-lint]
select = ["MY"]              # only run rules matching these prefixes (empty = all)
ignore = ["MY002"]           # skip these rules globally
exclude = [".venv/**", "build/**"]
rules_path = "./rules"       # directory containing your custom rule modules

[tool.jg-lint.per-file-ignores]
"tests/**" = ["MY001"]       # skip MY001 in test files

Writing custom rules

1. Create a rule module

Put it inside the directory you've configured as rules_path (e.g. ./rules/no_todo.py or ./rules/no_todo/__init__.py).

from jg_linter import Rule, Violation


class NoTodoComments(Rule):
    code = "MY001"
    message = "TODO comments should be tracked as issues"

    def check(self, file_path: str, content: str) -> list[Violation]:
        violations = []
        for i, line in enumerate(content.splitlines(), 1):
            if "# TODO" in line:
                violations.append(
                    Violation(file_path, i, 1, self.code, self.message)
                )
        return violations


def get_rules() -> list[Rule]:
    return [NoTodoComments()]

Each rule needs:

  • code -- unique identifier (e.g. MY001)
  • message -- human-readable description
  • check(file_path, content) -- returns a list of Violation objects

Set test_only = True on a rule to run it only against test files (files named test_*.py, *_test.py, or inside a tests/ directory).

2. Point jg-lint at the rules folder

[tool.jg-lint]
rules_path = "./rules"

Every top-level .py file and package inside rules_path is imported automatically; any module exposing get_rules() contributes rules. Files and folders starting with _ are skipped. The rules directory is prepended to sys.path during loading, so no PYTHONPATH setup is needed.

3. Run

jg-lint check src/
src/app.py:3:1: MY001 TODO comments should be tracked as issues
src/utils.py:17:1: MY001 TODO comments should be tracked as issues

Found 2 violation(s)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jg_lint-0.3.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

jg_lint-0.3.0-cp315-cp315-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.15manylinux: glibc 2.17+ x86-64

jg_lint-0.3.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

jg_lint-0.3.0-cp314-cp314-win_amd64.whl (923.8 kB view details)

Uploaded CPython 3.14Windows x86-64

jg_lint-0.3.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

jg_lint-0.3.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

jg_lint-0.3.0-cp314-cp314-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

jg_lint-0.3.0-cp314-cp314-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

File details

Details for the file jg_lint-0.3.0.tar.gz.

File metadata

  • Download URL: jg_lint-0.3.0.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jg_lint-0.3.0.tar.gz
Algorithm Hash digest
SHA256 37fbc26751563ab0d339dbb547eacb32412a06d150e96a333b04d7c2b2a8eb52
MD5 e567a5d959072b1590dca56c127a0d83
BLAKE2b-256 d961b76796a58fdb89e35e50206bbd57695887b9364aff8d26c56c9f0aa14861

See more details on using hashes here.

Provenance

The following attestation bundles were made for jg_lint-0.3.0.tar.gz:

Publisher: release.yml on jangia/jg-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jg_lint-0.3.0-cp315-cp315-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for jg_lint-0.3.0-cp315-cp315-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c97a0f82a5c653678f3842a5bcfbdf14526678f09b2a50bd31974f44fcf60d1
MD5 4301f604dd0d70cdd4809fcb01cfdbe4
BLAKE2b-256 0041fb497dc278da65ff39a5f6f97d1e2a3667569f06d41f3b0ce76057a1af49

See more details on using hashes here.

Provenance

The following attestation bundles were made for jg_lint-0.3.0-cp315-cp315-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on jangia/jg-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jg_lint-0.3.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for jg_lint-0.3.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7f02ac307449ccfa34729689cc918a66523a97c7154affa8e81adb276c78890f
MD5 7f088d909dcd83df4ee3fdb1f04b4338
BLAKE2b-256 6e8b2dcc06719bec9e45aa4dbfe5a1f8c3bfe05662f5f67181211d45c304aa69

See more details on using hashes here.

Provenance

The following attestation bundles were made for jg_lint-0.3.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on jangia/jg-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jg_lint-0.3.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: jg_lint-0.3.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 923.8 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jg_lint-0.3.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 af71420fedcbf0e1ae722babced1e7490b1bf0bcbf5783a7579795364b16572e
MD5 7ab66a1d046dfb1ca1411593ebb806ca
BLAKE2b-256 a9749da9c82051fcf26af19dfe8a4494faf34fa2ed9f3c1463c911c942aaa9b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for jg_lint-0.3.0-cp314-cp314-win_amd64.whl:

Publisher: release.yml on jangia/jg-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jg_lint-0.3.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for jg_lint-0.3.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e160eac4b369f75d6663c5257fef7051c2ea1d2b6004ef8e29c4cffebca7f5e6
MD5 429c040072bfc76dfdffc7952e02b1ab
BLAKE2b-256 b40b67c57e4eb485f9e3fb88f3f5d7e174f0e4a87ec26ba4ec61a6d12e4590f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for jg_lint-0.3.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on jangia/jg-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jg_lint-0.3.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for jg_lint-0.3.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 98c27c03e01e9f0351ca30fe6f91ea5919604f545169d763df07d3157c4328b2
MD5 ab2ee6bd2a7ab546a0077e393b9ef145
BLAKE2b-256 d5d0fded283656cd8c7970ef5f21fef433b98435bd74ca7f3b6651be4b53d173

See more details on using hashes here.

Provenance

The following attestation bundles were made for jg_lint-0.3.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on jangia/jg-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jg_lint-0.3.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for jg_lint-0.3.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cc1f3c943f405126fd5fe926ae30c19f3f4c8560f0d6ae8d2c09a27c6205f15d
MD5 19a064d2f5f7225f578c7e057df6c0c0
BLAKE2b-256 1e7cc8b69da000198a05bdee1a4d90f4b9efd0af5941caed85594a27f624dcc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for jg_lint-0.3.0-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on jangia/jg-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jg_lint-0.3.0-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for jg_lint-0.3.0-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4ca6c8d089bcadbd2283b8ff9f1f21ee754ec2fafc89564cc5dc1238ccb9fd32
MD5 27597ad120d487122368ba8186d0eebc
BLAKE2b-256 0ceb5b6e44ca0ff60b526e4d9e19b51a092b25697765c7245e5f43c703e7be7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for jg_lint-0.3.0-cp314-cp314-macosx_10_12_x86_64.whl:

Publisher: release.yml on jangia/jg-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page