Python API reference#
Stable entry points for embedding jaxlint. These pages use autodoc and a compact autosummary index of jaxlint.core re-exports.
jaxlint.core does not import JAX. Optional jaxlint[hlo] is documented narratively in HLO extra (jaxlint[hlo]); API HTML for jaxlint.hlo is not built here so doc builds stay free of the JAX stack.
jaxlint.core summary
Diagnostic(rule_id: 'str', severity: 'Severity', message: 'str', path: 'Path', line: 'int', col: 'int' = 0, end_line: 'int | None' = None, end_col: 'int | None' = None) |
|
|
Built-in mutable sequence. |
One line per diagnostic: |
|
JSON shaped for GitHub Checks output.annotations (REST API field names). |
|
Minimal SARIF 2.1.0 log (best-effort for generic viewers; not GHAS-specific). |
|
Format diagnostics for CLI / library use. |
Public core API surface.
- class jaxlint.core.Diagnostic(rule_id: 'str', severity: 'Severity', message: 'str', path: 'Path', line: 'int', col: 'int' = 0, end_line: 'int | None' = None, end_col: 'int | None' = None)#
Bases:
object
- jaxlint.core.run_checks(paths: list[Path], *, cfg: LintConfig | None = None, perf: bool = True, doc: bool = True, mathjx: bool = True, config_start: Path | None = None, jobs: int | None = None, cache_dir: Path | None = None) list[Diagnostic]#
- jaxlint.core.diagnostics_for_python_source(path: Path, source: str, *, cfg: LintConfig | None = None, perf: bool = True, doc: bool = True, mathjx: bool = True, config_start: Path | None = None) list[Diagnostic]#
Lint in-memory Python source for
path(unsaved buffers, LSP, etc.).Semantics match
_diagnostics_for_file()for the samepath, flags, and config, butsourceis used instead of reading the file from disk. Results are sorted byDiagnostic.sort_key()(same contract asrun_checks()for a single path).The language server does not use the on-disk diagnostic cache (
cache_dir); callers should omit caching for editor buffers.
- jaxlint.core.format_compact(diagnostics: list[Diagnostic]) str#
One line per diagnostic:
path:line:col: severity: message (rule_id).
- jaxlint.core.format_text(diagnostics: list[Diagnostic]) str#
- jaxlint.core.format_json(diagnostics: list[Diagnostic]) str#
- jaxlint.core.format_github_annotations_json(diagnostics: list[Diagnostic]) str#
JSON shaped for GitHub Checks output.annotations (REST API field names).
Omits
start_column/end_columnwhenstart_line != end_line(GitHub requires columns only for single-line annotations). Uses 1-basedstart_column/end_column;col/end_colof0are treated as start of line (column 1).
- jaxlint.core.format_sarif(diagnostics: list[Diagnostic], *, tool_version: str, cfg: LintConfig | None = None) str#
Minimal SARIF 2.1.0 log (best-effort for generic viewers; not GHAS-specific).
- jaxlint.core.format_rich(diagnostics: list[Diagnostic]) str#
Render diagnostics as a Rich panel + table (ASCII-safe when stdout is not a TTY).
- jaxlint.core.format_diagnostics(diagnostics: list[Diagnostic], format_name: str, cfg: LintConfig | None = None) str#
Format diagnostics for CLI / library use.
cfgis used whenformat_nameis SARIF — pass the same LintConfig asrun_checks(or fromload_config) so optionalsarif-rule-docs-basecan populatehelpUrion rule descriptors.
Load lint settings from jaxlint.toml or pyproject.toml.
jaxlint.toml accepts a first-class [jaxlint] table or legacy [tool.jaxlint]
(but not both). pyproject.toml must use [tool.jaxlint] only — a top-level
[jaxlint] table is rejected.
- class jaxlint.core.config.LintConfig(select: 'frozenset[str]' = frozenset(), ignore: 'frozenset[str]' = frozenset(), docstring_style: 'str' = 'numpy', required_sections: 'tuple[str, ...]' = ('Parameters', 'Returns'), section_order: 'tuple[str, ...]' = ('Parameters', 'Returns', 'Raises', 'Examples', 'Pseudocode', 'Hardware Notes'), strict_shapes: 'bool' = False, rubric_threshold: 'float' = 0.75, per_file_ignores: 'dict[str, tuple[str, ...]]' = <factory>, cache_dir: 'Path | None' = None, severity_overrides: 'dict[str, Severity]' = <factory>, sarif_rule_docs_base: 'str | None' = None)#
Bases:
object- section_order: tuple[str, ...] = ('Parameters', 'Returns', 'Raises', 'Examples', 'Pseudocode', 'Hardware Notes')#
- classmethod default() LintConfig#
- jaxlint.core.config.load_config(start: Path | None = None) LintConfig#
Load lint configuration from the discovery walk or a direct config file path.
jaxlint.tomlmay use native[jaxlint]or legacy[tool.jaxlint](mutually exclusive).pyproject.tomlonly allows[tool.jaxlint].startisNone— walk upward from the current working directory.startis a directory — walk upward fromstart.resolve()([root] + root.parents).startis a file — parsejaxlint.tomlorpyproject.tomlat that path (no walk); relative TOML paths resolve against the directory containing the file.
- jaxlint.core.config.effective_severity(d: Diagnostic, cfg: LintConfig) Diagnostic#
Apply
severity-overridesso configured severity always wins (after rule selection).
- jaxlint.core.config.rule_enabled(rule_id: str, cfg: LintConfig, file_path: Path) bool#
Apply select/ignore and per-file-ignores (glob patterns).