oct
Loading...
Searching...
No Matches
diagnostics.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# oct/core/diagnostics.py
4
5"""
6Purpose
7-------
8OI-525 - single source of truth for the ``_dbg()`` import used across OCT
9modules. The ``oc_diagnostics`` package is an optional runtime dependency;
10when unavailable (dev-time tooling, partial installs, tests running outside
11a full environment) ``_dbg()`` becomes a no-op so callers never crash.
12
13Responsibilities
14----------------
15- Expose ``_dbg`` re-bound from ``oc_diagnostics`` when importable.
16- Fall back to a no-op stub whose signature is EXACTLY ``oc_diagnostics._dbg``'s
17 (names, kinds, defaults) - no extra tolerance, so code that only ever ran
18 against the stub cannot silently depend on laxness the real callable
19 rejects (the plan-213 E0 lesson).
20- Never raise on import.
21
22Diagnostics
23-----------
24Domain: OCT-CORE
25Levels:
26 L2 - reserved (this module provides the plumbing and emits nothing itself)
27 L3 - reserved
28 L4 - reserved
29
30Contracts
31---------
32- Every OCT module that needs ``_dbg`` must import from here rather than
33 duplicating the try/except stub.
34- Signature must match ``oc_diagnostics._dbg`` so swap is transparent.
35
36Dependencies
37------------
38- oc_diagnostics (the real _dbg, re-exported when the package is importable)
39"""
40
41# OCT-LINT: disable-file=dbg_import reason="Plan 263: this module IS the fail-soft _dbg source, and a module-level self-import would resolve before the definition and raise ImportError"
42# OCT-LINT: disable-file=dbg_usage reason="Plan 263: the shim provides the plumbing and emits nothing itself, as its reserved-level Diagnostics profile states"
43
44from __future__ import annotations
45
46try:
47 from oc_diagnostics import _dbg # type: ignore[assignment]
48except ImportError: # pragma: no cover - diagnostics optional at dev time
49 def _dbg(
50 domain: str,
51 func: str,
52 msg: str,
53 level: int | str | None = None,
54 override: bool = False,
55 _depth: int = 1,
56 ) -> None:
57 return None
58
59
60__all__ = ["_dbg"]
None _dbg(str domain, str func, str msg, int|str|None level=None, bool override=False, int _depth=1)