Skip to content

feat: add ast plugin to read a global literal from a Python file#81

Merged
henryiii merged 1 commit into
mainfrom
ast-plugin
Jul 3, 2026
Merged

feat: add ast plugin to read a global literal from a Python file#81
henryiii merged 1 commit into
mainfrom
ast-plugin

Conversation

@henryiii

@henryiii henryiii commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Adds a dynamic_metadata.ast plugin: given input (a Python file), name (a module-level global), and field, it parses the file with ast — never importing it — and returns the literal value via ast.literal_eval. Annotated assignments work, and the last assignment wins, matching execution semantics. Unlike regex, the value keeps its Python shape, so list/table fields can be filled directly (tuples become lists); shape validation reuses _process_dynamic_metadata.

Also extracts the string-settings validation loop shared with regex into _require_str_settings (pylint duplicate-code).

@henryiii henryiii merged commit 91fbde0 into main Jul 3, 2026
11 checks passed
@henryiii henryiii deleted the ast-plugin branch July 3, 2026 19:17
@henryiii henryiii mentioned this pull request Jul 4, 2026
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.

1 participant