Option C Tools
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 that accepts the same (domain, func, msg, level)
17 positional signature plus any keyword arguments.
18- Never raise on import.
19
20Diagnostics
21-----------
22Domain: OCT-CORE
23Levels:
24 (This module does not emit diagnostics; it provides the plumbing.)
25
26Contracts
27---------
28- Every OCT module that needs ``_dbg`` must import from here rather than
29 duplicating the try/except stub.
30- Signature must match ``oc_diagnostics._dbg`` so swap is transparent.
31"""
32
33from __future__ import annotations
34
35try:
36 from oc_diagnostics import _dbg # type: ignore[assignment]
37except ImportError: # pragma: no cover - diagnostics optional at dev time
38 def _dbg(*args, **kwargs) -> None:
39 return None
40
41
42__all__ = ["_dbg"]
None _dbg(*args, **kwargs)