Skip to main content

Fast validation and schema extraction for GenLayer intelligent contracts

Project description

genvm-linter

Fast validation and schema extraction for GenLayer intelligent contracts.

Installation

pip install genvm-linter

Usage

# Run both lint and validate (default)
genvm-lint check contract.py

# Fast AST safety checks only (~50ms)
genvm-lint lint contract.py

# Full SDK semantic validation (~200ms cached)
genvm-lint validate contract.py

# Extract ABI schema
genvm-lint schema contract.py
genvm-lint schema contract.py --output abi.json

# Pyright type checking with SDK auto-configured
genvm-lint typecheck contract.py
genvm-lint typecheck contract.py --strict      # Strict mode
genvm-lint typecheck contract.py --all         # Show all errors (disable SDK suppressions)

# IDE setup — download SDK and output extraPaths for Pylance
genvm-lint setup                               # Latest version
genvm-lint setup --contract contract.py        # Auto-detect version from header
genvm-lint setup --version v0.2.12             # Specific version
genvm-lint setup --json                        # JSON output for IDE integration

# Pre-download GenVM artifacts
genvm-lint download                    # Latest
genvm-lint download --version v0.2.12  # Specific version
genvm-lint download --list             # Show cached

# JSON output (all commands)
genvm-lint check contract.py --json

How It Works

Layer 1: AST Lint Checks (Fast)

  • Forbidden imports (random, os, time, etc.)
  • Non-deterministic patterns (float(), time.time())
  • Structure validation (dependency header)

Layer 2: SDK Validation (Accurate)

  • Downloads GenVM release artifacts (cached at ~/.cache/genvm-linter/)
  • Loads exact SDK version specified in contract header
  • Validates types, decorators, storage fields
  • Extracts ABI schema

Exit Codes

  • 0 - All checks passed
  • 1 - Lint or validation errors
  • 2 - Contract file not found
  • 3 - SDK download failed

IDE Integration

VS Code Extension

This linter is used by the GenLayer VS Code Extension for real-time contract validation.

Manual Pylance Setup

Use genvm-lint setup to configure Pylance with the correct SDK paths. This gives you hover docs, go-to-definition, and type checking without the extension.

genvm-lint setup --contract contract.py

Add the output paths to your VS Code settings.json:

{
  "python.analysis.extraPaths": ["<output paths>"],
  "python.analysis.reportMissingModuleSource": "none"
}

Type Checking

genvm-lint typecheck runs Pyright with the SDK auto-configured. By default it suppresses SDK-internal noise (dynamic attributes, NewType compat). Use --all to see everything, --strict for strict mode.

Development

git clone https://github.com/genlayerlabs/genvm-linter.git
cd genvm-linter
pip install -e ".[dev]"
pytest

License

MIT

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

genvm_linter-0.9.0.tar.gz (55.8 kB view details)

Uploaded Source

Built Distribution

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

genvm_linter-0.9.0-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file genvm_linter-0.9.0.tar.gz.

File metadata

  • Download URL: genvm_linter-0.9.0.tar.gz
  • Upload date:
  • Size: 55.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for genvm_linter-0.9.0.tar.gz
Algorithm Hash digest
SHA256 ef7dc1094ba30b95331401e5a20cec7f8ed8bd290c20a63ecd5412ba7f42bb96
MD5 d7063a143be5df749f27e2bf5517a229
BLAKE2b-256 b99ffe4e75b45df69a6b2842758288026de88f37f714019d2753ed159129a70f

See more details on using hashes here.

File details

Details for the file genvm_linter-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: genvm_linter-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for genvm_linter-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 982c93778cbbcc0c946d6ced6d17330433be024bfe2cb6d348c84fb66558ebe7
MD5 5e5c76d0ad5d301a23b90b8eadb6dc47
BLAKE2b-256 b3e9a10a94a0c2f7373c2ba5afb3aafd0f6fc995d620fc621f59d2b06344b6aa

See more details on using hashes here.

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