Skip to content

refactor: the expression parser is package-private, and the parsed tree is named apart from the program's - #342

Merged
FBumann merged 2 commits into
mainfrom
refactor/private-expression-parser
Sep 2, 2026
Merged

refactor: the expression parser is package-private, and the parsed tree is named apart from the program's#342
FBumann merged 2 commits into
mainfrom
refactor/private-expression-parser

Conversation

@FBumann

@FBumann FBumann commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Prompt: "Lets work on #337, starting from pulled main!"

Note

The following content was generated by AI.

expression_parser.py becomes _expression_parser.py — package-private and off the generated API docs (the docs hooks skip _*.py), the end state #323 gave the where grammar. The public surface is now exactly Spec + Program, with everything between private; __init__'s "reachable by module path for a renderer" sentence dies with the exposure it described. The parsed union is renamed ParsedNode, so ExpressionNode means one thing in the package: the lowered vocabulary a consumer reads. Closes #337.

Breaking (described here per the refused-marker rule): importers of math_spec.expression_parser break on the module path. There is no known external importer — no lpspec repo exists, docs never referenced the module — so the break is theoretical.

Two sentences swept with the decision: __init__'s "stays path-reachable deliberately" paragraph (written in #327, before #337 decided otherwise), and the module docstring's claim that the AST "can be evaluated against a namespace of linopy variables and xarray parameters" — an engine claim #315 retired from the program side.

Stack: on #346, at the maintainer's direction — the small independent diff goes to main first, the rename rides on it.

Verified

pixi run ci exit 0 in this worktree on #346's head (itself on origin/main post-#345): lint clean, 1011 passed, mkdocs build --strict builds (the module's API page drops out via the hooks' [!_]*.py glob — a dangling nav entry would fail the strict build), 27 TeX documents compile; working tree clean after the run. git grep math_spec.expression_parser finds nothing; ParsedNode lives in _expression_parser with four internal importers (degree, dimensions, expansion, resolution).

No behaviour change — every test passes untouched except import paths; the 13 lint fixes in the diff are ruff's import re-sorts for the underscored name.

Deliberately not done: renaming ArithmeticNode (no collision), and any grammar/AST split within the private module — privacy removes the reason the where side needed one.

@read-the-docs-community

read-the-docs-community Bot commented Sep 1, 2026

Copy link
Copy Markdown

@FBumann
FBumann force-pushed the refactor/private-expression-parser branch from 9542897 to bb4cf0a Compare September 1, 2026 16:34
@FBumann
FBumann force-pushed the refactor/private-expression-parser branch from bb4cf0a to c8b55ae Compare September 1, 2026 16:49
@FBumann
FBumann force-pushed the refactor/private-expression-parser branch from c8b55ae to b5a5413 Compare September 1, 2026 17:05
@FBumann
FBumann changed the base branch from main to feat/where-parse-failure-names-rewrite September 1, 2026 17:05
Base automatically changed from feat/where-parse-failure-names-rewrite to main September 1, 2026 17:11
…ee is named apart from the program's

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9qaMS43V6yaNApJPmuWtM
@FBumann
FBumann force-pushed the refactor/private-expression-parser branch from b5a5413 to 3b7bcbf Compare September 1, 2026 17:11
@FBumann
FBumann merged commit 55ff525 into main Sep 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the expression grammar stayed public by path after the where grammar went private, and nothing says for whom

1 participant