Smart contract linter for the Xian blockchain
Project description
xian-linter
xian-linter is a Python linter specifically for Xian smart contracts. It
combines PyFlakes with authoritative Rust compiler diagnostics exposed by
xian-contracting, so rule violations match Python,
WASM/JavaScript, and validator deployment admission.
The published PyPI package is xian-tech-linter. The import package and
console command remain xian_linter and xian-linter. The package can be
used inline (as a dependency in another tool) or as an HTTP server when the
server extra is installed.
Linting Shape
flowchart LR
Source["Contract source"] --> API["Inline API or HTTP server"]
API --> Pyflakes["PyFlakes checks"]
API --> Contracting["xian-contracting structured linter"]
Contracting --> VM["Optional xian_vm_v1 validation"]
Pyflakes --> Results["Stable diagnostics"]
Contracting --> Results
VM --> Results
Results --> Tools["IDE, hub, CI, and scripts"]
Quick Start
Install the base package:
uv add xian-tech-linter
Lint inline (lightweight, position-only diagnostics):
from xian_linter import lint_code_inline
errors = lint_code_inline("def transfer():\n pass\n")
Get fully-typed structured results:
from xian_linter import LintErrorModel, lint_code_sync
errors: list[LintErrorModel] = lint_code_sync(
"@export\ndef transfer():\n return missing_name\n"
)
Validate against the xian_vm_v1 target:
uv add "xian-tech-linter[vm]"
from xian_linter import lint_code_sync
errors = lint_code_sync(source, mode="xian_vm_v1")
Run as a standalone HTTP server:
uv add "xian-tech-linter[server]"
xian-linter
# defaults to http://127.0.0.1:8000
Principles
- Linting only. The package focuses on contract linting; runtime execution and contract submission belong elsewhere.
- One compiler authority, multiple integration modes. Inline and server
modes expose the same Rust compiler rules and
xian.*diagnostic codes. - Compatible mode names without duplicated semantics. Both
pythonandxian_vm_v1use the Rust compiler; the names remain API-compatible. VM mode additionally uses the nativexian_vm_coreIR validator when installed. - Stable codes and positions. Tooling (IDE plugins, CI gates, the contracting hub) can rely on consistent error codes and source positions to render diagnostics.
- Importable from the root.
LintErrorModel,lint_code_inline, andlint_code_syncare importable from the package root — callers do not reach into internal modules. - Optional server. The core package is useful as a local linting dependency without installing the server extra.
Key Directories
xian_linter/— package code:linter.py— core lint engine combining PyFlakes and the structuredxian-contractinglinter.server.py— optional FastAPI / ASGI server (serverextra).__main__.py—xian-linterconsole entrypoint.
tests/— inline and server-mode coverage.docs/— architecture and backlog notes.
Usage Modes
-
Inline / programmatic — for in-process linting from another Python tool:
from xian_linter import lint_code_inline, lint_code_sync inline_errors = lint_code_inline("def transfer():\n pass\n") sync_errors = lint_code_sync("def transfer():\n pass\n") vm_errors = lint_code_sync(source, mode="xian_vm_v1")
-
HTTP server — for editor / IDE integrations, CI runners, or remote linting from web frontends:
uv add "xian-tech-linter[server]" xian-linter
Select the VM target with
?mode=xian_vm_v1on/lint,/lint_base64, or/lint_gzip. Installxian-tech-linter[server,vm]when the server should also run native IR validation throughxian_vm_core.HTTP mode is local by default. Use
XIAN_LINTER_HOSTandXIAN_LINTER_PORTto change the bind address. SetXIAN_LINTER_HOST=::1when the server should bind to IPv6 loopback instead of the default IPv4 loopback address:XIAN_LINTER_HOST=::1 XIAN_LINTER_PORT=8000 xian-linter
Use a non-loopback host such as
0.0.0.0only when publishing the service deliberately, preferably behind a rate-limited reverse proxy.Browser CORS defaults to local origins only. Set
XIAN_LINTER_CORS_ORIGINSto a comma-separated allowlist when a hosted IDE or frontend should call the service. The default local-origin regex includeslocalhost,127.0.0.1, and bracketed IPv6 loopback origins such ashttp://[::1]:5173:XIAN_LINTER_CORS_ORIGINS=https://ide.example xian-linter
Lint transports accept at most 1 MB bodies, while compiler admission accepts at most 128 KiB contract source.
/lint_gzipenforces the transport limit on both compressed and decompressed bytes and rejects extreme compression ratios.
Compiler admission also caps statement/expression nodes at 50,000, syntax
depth at 64, total tokens at 100,000, tokens on one logical line at 4,096,
canonical IR JSON at 1 MiB, and contract-handle inference at 512 passes. Limit
failures use stable xian.limit.* codes.
Validation
uv sync --group dev
uv run ruff check .
uv run ruff format --check .
uv run pytest
Related Docs
- AGENTS.md — repo-specific guidance for AI agents and contributors
- docs/README.md — index of internal docs
- docs/ARCHITECTURE.md — major components and dependency direction
- docs/BACKLOG.md — open work and follow-ups
- docs/RELEASING.md — fail-closed tag and package release process
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xian_tech_linter-0.4.0.tar.gz.
File metadata
- Download URL: xian_tech_linter-0.4.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad5a08fd47389d4eb78f126f1c459b87351e006b8ffdccc3c039fc28d4ff0981
|
|
| MD5 |
eb90189b80febb94d80b2eccb2344c12
|
|
| BLAKE2b-256 |
2118d197b656619be5a2f02029f7e30a79603eaf71ee7aef9f729b77d95f1454
|
Provenance
The following attestation bundles were made for xian_tech_linter-0.4.0.tar.gz:
Publisher:
release.yml on xian-technology/xian-linter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xian_tech_linter-0.4.0.tar.gz -
Subject digest:
ad5a08fd47389d4eb78f126f1c459b87351e006b8ffdccc3c039fc28d4ff0981 - Sigstore transparency entry: 2139197023
- Sigstore integration time:
-
Permalink:
xian-technology/xian-linter@a2f366e4d230e538b53e4e12ac0e60cfacb3177f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/xian-technology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a2f366e4d230e538b53e4e12ac0e60cfacb3177f -
Trigger Event:
push
-
Statement type:
File details
Details for the file xian_tech_linter-0.4.0-py3-none-any.whl.
File metadata
- Download URL: xian_tech_linter-0.4.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d9616455c514c5672acc1f9b26d79d4e9b3413bf72d6ca275377a057f7fc529
|
|
| MD5 |
594d2ca4a2edfac5b1765dfe2b634799
|
|
| BLAKE2b-256 |
017e4e092f60ac81669373df1f4a443ff2c83d3770f9ba6d41314081c5e02966
|
Provenance
The following attestation bundles were made for xian_tech_linter-0.4.0-py3-none-any.whl:
Publisher:
release.yml on xian-technology/xian-linter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xian_tech_linter-0.4.0-py3-none-any.whl -
Subject digest:
7d9616455c514c5672acc1f9b26d79d4e9b3413bf72d6ca275377a057f7fc529 - Sigstore transparency entry: 2139197026
- Sigstore integration time:
-
Permalink:
xian-technology/xian-linter@a2f366e4d230e538b53e4e12ac0e60cfacb3177f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/xian-technology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a2f366e4d230e538b53e4e12ac0e60cfacb3177f -
Trigger Event:
push
-
Statement type: