jellycell.lint.rules¶
Lint rule registry and rule implementations.
Each rule is a function (Project) -> list[Violation]. Fixers apply
auto-fixes for violations marked fixable=True.
Rules in this file:
layout— all declared path roots exist (always on).pep723-position— the PEP-723 block (if any) is at the top (always on).enforce-artifact-paths—jc.save/jc.figure/jc.tablecalls write intopaths.artifacts. Gated bylint.enforce_artifact_paths.enforce-declared-deps— named cells that reference another cell’s name viajc.loadmust declare it indeps=(or have it picked up by the AST walker). Gated bylint.enforce_declared_deps.deps-no-comma— catchesdeps=a,b,ctags that nbformat would reject at validation time; auto-fixes to onedeps=tag per dep.warn-on-large-cell-output— cached outputs exceeding the size threshold get a (non-fixable) warning. Gated bylint.warn_on_large_cell_output.
Module Contents¶
Classes¶
A single lint finding. |
Functions¶
Check that declared path roots exist (spec §2.1). |
|
Create the missing directory. |
|
Check every notebook’s PEP-723 block is at the top of the file (spec §7). |
|
Auto-fix by moving the block to the top of the file. |
|
AST-scan notebooks for |
|
Cells that |
|
Catch |
|
Rewrite |
|
Cached cells whose total output size exceeds |
|
Run every registered rule. Returns violations in a stable order. |
|
Apply registered fixers. Returns the list of remaining violations. |
Data¶
API¶
- class jellycell.lint.rules.Violation¶
A single lint finding.
fixable=Trueindicates a registered fixer exists and can attempt to resolve this violation automatically.- path: pathlib.Path | None¶
None
- jellycell.lint.rules.RuleFn¶
None
- jellycell.lint.rules.FixerFn¶
None
- jellycell.lint.rules.rule_layout(project: jellycell.paths.Project) list[jellycell.lint.rules.Violation]¶
Check that declared path roots exist (spec §2.1).
- jellycell.lint.rules.fix_layout(project: jellycell.paths.Project, violation: jellycell.lint.rules.Violation) bool¶
Create the missing directory.
- jellycell.lint.rules.rule_pep723_position(project: jellycell.paths.Project) list[jellycell.lint.rules.Violation]¶
Check every notebook’s PEP-723 block is at the top of the file (spec §7).
- jellycell.lint.rules.fix_pep723_position(project: jellycell.paths.Project, violation: jellycell.lint.rules.Violation) bool¶
Auto-fix by moving the block to the top of the file.
- jellycell.lint.rules.rule_enforce_artifact_paths(project: jellycell.paths.Project) list[jellycell.lint.rules.Violation]¶
AST-scan notebooks for
jc.save/figure/tablecalls with paths outsideartifacts/.
- jellycell.lint.rules.rule_enforce_declared_deps(project: jellycell.paths.Project) list[jellycell.lint.rules.Violation]¶
Cells that
jc.load(...)from another cell’s artifact must declare the dep.
- jellycell.lint.rules.rule_deps_no_comma(project: jellycell.paths.Project) list[jellycell.lint.rules.Violation]¶
Catch
deps=a,b,c— nbformat rejects any tag containing a comma.nbformat’s tag schema enforces
^[^,]+$on every individual tag string, so a comma-separated deps form (deps=a,b,c) raisesNotebookValidationErroron firstjellycell run. The valid form is onedeps=tag per dep — jellycell concatenates them at parse time. Fix is mechanical; registered as fixable.
- jellycell.lint.rules.fix_deps_no_comma(project: jellycell.paths.Project, violation: jellycell.lint.rules.Violation) bool¶
Rewrite
"deps=a,b,c"into"deps=a", "deps=b", "deps=c"in place.
- jellycell.lint.rules.rule_warn_on_large_cell_output(project: jellycell.paths.Project) list[jellycell.lint.rules.Violation]¶
Cached cells whose total output size exceeds
warn_on_large_cell_output.
- jellycell.lint.rules.RULES: dict[str, jellycell.lint.rules.RuleFn]¶
None
- jellycell.lint.rules.FIXERS: dict[str, jellycell.lint.rules.FixerFn]¶
None
- jellycell.lint.rules.run_all(project: jellycell.paths.Project) list[jellycell.lint.rules.Violation]¶
Run every registered rule. Returns violations in a stable order.
- jellycell.lint.rules.auto_fix(project: jellycell.paths.Project, violations: list[jellycell.lint.rules.Violation]) list[jellycell.lint.rules.Violation]¶
Apply registered fixers. Returns the list of remaining violations.
Violations are considered “remaining” if:
fixableis False, orNo fixer is registered for the rule, or
The fixer returned
False(couldn’t fix).