simvx.editor.refactor_inline¶
Inline a folder-as-package back into a single .py file.
The “Inline folder to file” refactoring is the inverse of
- func:
simvx.editor.refactor_extract.extract_to_folder. It takessrc/things/(a package with__init__.pyre-exporting per-file classes) and producessrc/things.pycontaining every class.
Refusal cases (raise :class:FolderInlineRefused) when force=False:
Module-level side effects in any file (statements that are neither imports, classes, function defs, nor
__all__assignments).Conditional imports (
if sys.version_info: import X).Cross-folder circular imports.
__init__.pycarries executable code beyond re-exports.
When force=True, the inline proceeds best-effort. Each suspect
construct is captured in :attr:InlineResult.flagged so the editor can
display a review report — the generated source itself is left clean
(no inserted markers, no comments).
Module Contents¶
Classes¶
Outcome of :func: |
Functions¶
Concatenate every class in |
Data¶
API¶
- simvx.editor.refactor_inline.log¶
‘getLogger(…)’
- exception simvx.editor.refactor_inline.FolderInlineRefused(message: str, issues: list[tuple[pathlib.Path, int, str]])[source]¶
Bases:
ValueErrorRaised when a folder cannot be cleanly inlined and
force=False.Initialization
Initialize self. See help(type(self)) for accurate signature.
- class __cause__¶
- class __context__¶
- __delattr__()¶
- __dir__()¶
- __eq__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __le__()¶
- __lt__()¶
- __ne__()¶
- __new__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __setattr__()¶
- __setstate__()¶
- __sizeof__()¶
- __str__()¶
- __subclasshook__()¶
- class __suppress_context__¶
- class __traceback__¶
- add_note()¶
- class args¶
- with_traceback()¶
- class simvx.editor.refactor_inline.InlineResult[source]¶
Outcome of :func:
inline_to_file.- file: pathlib.Path¶
None
- deleted_folder: pathlib.Path¶
None
- flagged: list[tuple[pathlib.Path, int, str]]¶
‘field(…)’
Per-issue audit trail when
force=Trueproceeded over warnings.
- simvx.editor.refactor_inline.inline_to_file(folder_path: pathlib.Path, project_index: simvx.editor.project_classes.ProjectClassIndex | None = None, *, force: bool = False) simvx.editor.refactor_inline.InlineResult[source]¶
Concatenate every class in
folder_pathinto a single.pyfile.The new file lands at
folder_path.parent / (folder_path.name + ".py"). The folder is deleted on success.Refusal conditions are detected up front; when
force=Falseand any issue exists, :class:FolderInlineRefusedis raised with the full audit trail in.issues. Whenforce=True, the inline proceeds and the same audit trail lands in :attr:InlineResult.flagged.project_index.refresh()runs at the end so callers see the new layout. May beNonefor one-shot scripted use.