oct
Loading...
Searching...
No Matches
__init__.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# oct/migrate/__init__.py
4
5"""
6Purpose
7-------
8FS-539: the ``oct migrate`` subpackage, which moves a project onto the
9Option C ``.option_c/`` layout. This file is the package shell only; the
10command and every migration step live in
11:mod:`oct.migrate.oct_migrate`.
12
13Responsibilities
14----------------
15- Expose ``migrate_group`` as this package's single public name.
16- Resolve it LAZILY through :func:`__getattr__`, so importing
17 ``oct.migrate`` alone does not import click or the migration engine.
18 ``oct.cli`` does resolve it at import, to register the command.
19
20Diagnostics
21-----------
22Domain: OCT-MIGRATE
23Levels:
24 L1 - errors: none raised here; the engine owns failure reporting
25 L2 - (none) the lazy re-export resolves before diagnostics start
26 L3 - (none) the migrate command reports in its own module
27 L4 - (none)
28
29Contracts
30---------
31- Import-time side effects: none beyond the ``_dbg`` shim. No migration
32 submodule is imported until an attribute is requested.
33- Emits no ``_dbg`` record: ``__getattr__`` runs during ``import oct.cli``,
34 before ``oc_diagnostics.init()``, so a record here printed the "called
35 before init()" RuntimeWarning on every oct invocation (plan 263's rule
36 for lazy package roots; found again by the chart C runtime trace,
37 2026-09-27).
38- Any name other than ``migrate_group`` raises ``AttributeError``, so a
39 typo fails loudly instead of returning ``None``.
40- ``__all__`` and :func:`__getattr__` must agree; a name added to one
41 without the other is unreachable or undeclared.
42
43Dependencies
44------------
45- oct.migrate.oct_migrate (lazy; the migrate command, resolved inside __getattr__)
46- oct.core.diagnostics (_dbg structured logger, imported but not called)
47"""
48
49# OCT-LINT: disable-file=dbg_usage reason="Plan 263: its lazy __getattr__ resolves during `import oct.cli`, before init(), so any _dbg call here would run before oc_diagnostics.init() and add a RuntimeWarning to every oct invocation"
50from oct.core.diagnostics import _dbg
51
52__all__ = ["migrate_group"]
53
54
55def __getattr__(name: str):
56 """Resolve ``migrate_group`` on first access; reject anything else."""
57 if name == "migrate_group":
58 from oct.migrate.oct_migrate import migrate as _migrate
59 return _migrate
60 raise AttributeError(f"module 'oct.migrate' has no attribute {name!r}")
__getattr__(str name)
Definition __init__.py:55