Linter Module (stx.linter)
AST-based Python linter enforcing SciTeX conventions for reproducible scientific code.
Note
stx.linter wraps the standalone
scitex-linter package.
Install with: pip install scitex-linter.
Quick Reference
# Check a file
scitex linter check my_script.py
# Check with specific severity
scitex linter check my_script.py --severity warning
# List all rules
scitex linter list-rules
# Filter by category
scitex linter list-rules --category session
from scitex_linter import check_file, list_rules
# Check a file
results = check_file("my_script.py")
# List available rules
rules = list_rules()
Rule Categories
45 rules across 8 categories:
Prefix |
Category |
Examples |
|---|---|---|
|
Session |
Missing |
|
Import |
Using |
|
I/O |
Using |
|
Plotting |
Using |
|
Statistics |
Using |
|
Path |
Hardcoded absolute paths, missing |
|
Format |
Non-snake_case names, magic numbers, missing docstrings |
Severity Levels
error – Must fix (breaks reproducibility or correctness)
warning – Should fix (best practice violations)
info – Suggestions for improvement
Interfaces
The linter is available through multiple interfaces:
CLI:
scitex linter check script.py
scitex-linter check script.py # standalone CLI
Python API:
from scitex_linter import check_file, check_source
results = check_file("script.py")
results = check_source("import numpy as np\n...")
Flake8 Plugin:
flake8 --select=STX script.py
MCP Tools:
# Available as MCP tools for AI agents
linter_check(path="script.py", severity="warning")
linter_list_rules(category="session")
linter_check_source(source="...", filepath="<stdin>")
Configuration
Configure via pyproject.toml:
[tool.scitex-linter]
severity = "warning"
ignore = ["STX-S002", "STX-FM001"]
API Reference
See scitex.linter for the auto-generated Python API.