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/git/__init__.py
4
5"""
6Purpose
7-------
8Phase 4B ``oct git`` package: user-facing Click commands, quality-gate
9orchestration, audit logging, and profile policy. Imported lazily by
10:mod:`oct.cli` via :func:`git_group` so that CLI startup does not pay
11the cost of loading the linter, formatter, or subprocess machinery for
12non-git commands.
13
14Responsibilities
15----------------
16- Expose the ``git`` Click command group for :mod:`oct.cli` registration.
17- Re-export the stable public API consumed by other oct modules.
18
19Contracts
20---------
21- All Click command functions go through the :func:`audited` decorator
22 defined in :mod:`oct.git.audit`.
23- Every read-only git state query delegates to :mod:`oct.core.git`
24 (Phase 4A foundation). This module never calls ``subprocess.run``
25 directly.
26- No write operations land in Phase 4B - both ``oct git status`` and
27 ``oct git check`` are strictly read-only. Writes come in Phase 4C/4D.
28
29Diagnostics
30-----------
31Domain: GIT
32Levels:
33 L2 - (none) the lazy re-export resolves before diagnostics start
34 L3 - (none) the git commands report in their own modules
35 L4 - (none)
36
37Dependencies
38------------
39- oct.core.diagnostics (_dbg imported but never called - the dbg_usage waiver says why)
40- oct.git.oct_git (lazy; the git Click group re-exported as git_group)
41"""
42
43# 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"
44from oct.core.diagnostics import _dbg
45
46__all__ = ["git_group"]
47
48
49def __getattr__(name: str):
50 """Lazy re-export of :data:`git_group` from :mod:`oct.git.oct_git`.
51
52 ``oct.git.oct_git`` imports Click and the linter/formatter
53 orchestrators, which are heavy. Using ``__getattr__`` keeps those
54 imports deferred until :mod:`oct.cli` actually touches the group,
55 mirroring the pattern the existing ``diag`` package uses.
56 """
57 if name == "git_group":
58 from oct.git.oct_git import git as _git
59 return _git
60 raise AttributeError(f"module 'oct.git' has no attribute {name!r}")
__getattr__(str name)
Definition __init__.py:49