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 takes src/things/ (a package with __init__.py re-exporting per-file classes) and produces src/things.py containing 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__.py carries 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

InlineResult

Outcome of :func:inline_to_file.

Functions

inline_to_file

Concatenate every class in folder_path into a single .py file.

Data

log

API

simvx.editor.refactor_inline.log

‘getLogger(…)’

exception simvx.editor.refactor_inline.FolderInlineRefused(message: str, issues: list[tuple[pathlib.Path, int, str]])[source]

Bases: ValueError

Raised 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=True proceeded 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_path into a single .py file.

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=False and any issue exists, :class:FolderInlineRefused is raised with the full audit trail in .issues. When force=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 be None for one-shot scripted use.