Warnings
wybthon._warnings¶
_warnings
¶
Development-mode warnings and error reporting.
A process-wide DEV_MODE flag and helpers that surface clear,
actionable messages during development while keeping production builds
quiet. All output goes to sys.stderr.
Dev-mode diagnostics raised elsewhere in the framework:
- Top-level reactive read: a signal, memo, or prop was called at the top level of a component body, where the read isn't tracked.
- Write in tracking scope: a signal was written inside a memo, a
single-function effect, or a reactive hole
(
WriteInScopeError). - Static list in
For:Forreceived a plain list instead of an accessor, so it will only render once.
Functions:
| Name | Description |
|---|---|
set_dev_mode |
Enable or disable development mode diagnostics globally. |
is_dev_mode |
Return whether development mode is currently active. |
warn |
Print a development-mode warning to |
warn_once |
Print |
log_error |
Log an error to |
component_name |
Return a human-readable display name for a component or tag. |
warn_each_plain_list |
Warn that |
Attributes:
| Name | Type | Description |
|---|---|---|
DEV_MODE |
bool
|
Process-wide flag toggling Wybthon's development diagnostics. |
DEV_MODE
module-attribute
¶
DEV_MODE: bool = True
Process-wide flag toggling Wybthon's development diagnostics.
Defaults to True. Production builds should call
set_dev_mode(False) at startup.
set_dev_mode
¶
set_dev_mode(enabled: bool) -> None
Enable or disable development mode diagnostics globally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
When |
required |
warn
¶
warn(message: str) -> None
Print a development-mode warning to stderr (no-op when dev mode is off).
warn_once
¶
Print message at most once per (category, key) pair.
log_error
¶
log_error(message: str, error: BaseException | None = None) -> None
Log an error to stderr, with a traceback in dev mode.
Always logs regardless of DEV_MODE, since errors indicate real
problems.
component_name
¶
Return a human-readable display name for a component or tag.
What's in this module¶
_warnings is Wybthon's lightweight development-mode diagnostics
layer. It gives the framework a single place to surface actionable
warnings and error tracebacks while developing. Warning output and
exception tracebacks can be disabled for production; error messages
still go to stderr.
Three things live here:
- Dev-mode toggling:
DEV_MODEdefaults toTrue. Callset_dev_mode(False)at startup to silence warnings and traceback printing for production builds. This also disablesWriteInScopeErrorfor signal and store writes inside tracking scopes.is_dev_mode()reports the current state. Both are re-exported from the top-levelwybthonpackage. - Warnings:
warnprints a message tostderrevery time it's called (a no-op when dev mode is off), whilewarn_oncededuplicates by a(category, key)pair so repeated calls with the same pair only log once per process. The reactive system uses this path for untracked reads of signals, memos, and props at the top level of a component body.warn_each_plain_listalso uses it whenForreceives a static list or tuple. - Error logging:
log_erroralways prints, regardless ofDEV_MODE; in dev mode it also prints the full traceback of an attached exception.
component_name is a small formatting helper shared by the warning
functions above to produce a readable name for a tag string, a
function component, or a class instance in warning text.
Application code doesn't usually call into _warnings directly beyond
set_dev_mode/is_dev_mode. The other helpers are used internally by
the reactive system and flow-control primitives to flag common
reactivity mistakes early.
See also¶
- Reactivity: explains tracked reads and
the
WriteInScopeErrordiagnostic. flow: callswarn_each_plain_listwhenForreceives a static list or tuple instead of an accessor.