xian-linter
xian-linter is a Python linter specifically for Xian smart contracts. It
combines PyFlakes with authoritative diagnostics from the Rust compiler core
(xian-tech-compiler-core, built from
xian-contracting's packages/xian-compiler-core), so
rule violations match Python, WASM/JavaScript, and validator deployment
admission. It does not depend on the contract runtime package
xian-tech-contracting.
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 --> Compiler["xian_compiler_core diagnostics and IR"]
Compiler --> VM["xian_vm_core IR validation"]
Pyflakes --> Results["Stable diagnostics"]
Compiler --> Results
VM --> Results
Results --> Tools["IDE, hub, CI, and scripts"]
Quick Start
To run the V2 linter from source, check out xian-linter and xian-contracting
as siblings (the compiler and VM packages build from its packages/). From the linter checkout, install the base environment:
uv sync --frozen
Lint a fresh-chain contract inline:
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"
)
The default target is xian_vm_v2. Compiler diagnostics, native IR validation,
and PyFlakes accept exact decimal parameters and the V2 rounding helpers.
To check a historical contract, pass mode="xian_vm_v1".
Run as a standalone HTTP server:
uv sync --frozen --extra server
uv run --no-sync 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. - Profile-specific validation. Both VM modes run the native IR validator
installed with the base package. The explicit legacy
pythonmode applies V1 compiler checks and PyFlakes and skips native IR validation. - 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,xian_compiler_corediagnostics andxian_vm_coreIR validation.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") legacy_errors = lint_code_sync(source, mode="xian_vm_v1")
-
HTTP server — for editor / IDE integrations, CI runners, or remote linting from web frontends:
uv sync --frozen --extra server uv run --no-sync xian-linter
All three lint endpoints (
/lint,/lint_base64,/lint_gzip) default toxian_vm_v2. Use?mode=xian_vm_v1to select the historical target.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
Raw and base64 bodies are read with a streaming size bound, independent of Content-Length. 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 (an
f-string counts one token per character of its content), canonical IR JSON at
1 MiB, contract-handle inference at 512 passes, and the work of its
whole-program analyses at 1,000,000 units. Limit failures use stable
xian.limit.* codes.
Validation
uv sync --group dev
uv run ruff check .
uv run ruff format --check .
uv run --extra server 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
Metadata
Release files for xian-tech-linter 0.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xian_tech_linter-0.4.3.tar.gz | 16.8 kB | With provenance | Details for xian_tech_linter-0.4.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xian_tech_linter-0.4.3-py3-none-any.whl | Python 3 | none | any | Details for xian_tech_linter-0.4.3-py3-none-any.whl |
Total release size: 27.0 kB
Release files / xian_tech_linter-0.4.3.tar.gz
| Download URL | xian_tech_linter-0.4.3.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
000a062afedb22bfffbc033fe109858c56abcb177472b1a02a70516d3dd84801
|
|
BLAKE2b-256 checksum How to use checksums |
7d911df67f82c84aa88a8cad8700243fe11e3c68fa93a75a480595f6d62550ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logRelease files / xian_tech_linter-0.4.3-py3-none-any.whl
| Download URL | xian_tech_linter-0.4.3-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb29aa2bbf908e44da9c9a756731865a9722c61bca9e7ed08f3cd2434502179d
|
|
BLAKE2b-256 checksum How to use checksums |
1eac9a831837ef558cecf17e2a5dcdb9eb5c66518a12e40a5bf308fc45b92a40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logSecurity for xian-tech-linter 0.4.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for xian_tech_linter-0.4.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.