jellycell.format.pep723¶
PEP-723 script block extraction and re-insertion.
Jupytext treats the # /// script block as a regular code cell and mutates
it on first round-trip (prepending a # %% marker). We strip the block
pre-parse and reinsert it verbatim post-write (spec §1 “piggyback map”,
§2.2 “Format”).
The block must be at the top of the file per spec §7; :func:position_ok is
used by the pep723-position lint rule.
See Also: PEP 723 — https://peps.python.org/pep-0723/
Module Contents¶
Functions¶
Extract the PEP-723 |
|
Insert a PEP-723 block ahead of |
|
Parse the TOML content of a PEP-723 block (strips the |
|
Extract |
|
Return |
|
Move a mid-file PEP-723 block to the top of |
Data¶
API¶
- jellycell.format.pep723.PEP723_PATTERN¶
‘compile(…)’
- jellycell.format.pep723.extract(text: str) tuple[str | None, str]¶
Extract the PEP-723
scriptblock fromtext.Returns:
(block, body).blockis the verbatim matched substring orNoneif no block is present.bodyistextwith the block removed. Round-trip byte-exact via :func:insert.
- jellycell.format.pep723.insert(block: str | None, body: str) str¶
Insert a PEP-723 block ahead of
body.Inverse of :func:
extractfor block-at-top inputs:insert(*extract(text)) == text.
- jellycell.format.pep723.parse_content(block: str) dict[str, Any]¶
Parse the TOML content of a PEP-723 block (strips the
#prefixes).
- jellycell.format.pep723.jellycell_overrides(block: str | None) dict[str, Any]¶
Extract
[tool.jellycell]overrides from a PEP-723 block, if any.Returns an empty dict if no block, no
[tool], or no[tool.jellycell].