pyqt_reactive.forms.widget_dispatcher
Widget dispatcher with fail-loud ABC checking.
Replaces duck typing (hasattr checks) with explicit isinstance checks against ABCs. All methods fail loud if widget doesn’t implement required ABC.
Design Philosophy: - Explicit over implicit - Fail-loud over fail-silent - Type-safe over duck-typed
Classes
ABC-based widget dispatch - NO DUCK TYPING. |
- class pyqt_reactive.forms.widget_dispatcher.WidgetDispatcher[source]
ABC-based widget dispatch - NO DUCK TYPING.
Replaces hasattr checks with explicit isinstance checks. Fails loud if widget doesn’t implement required ABC.
Example
# BEFORE (duck typing): if hasattr(widget, ‘get_value’):
value = widget.get_value()
# AFTER (ABC-based): value = WidgetDispatcher.get_value(widget) # Raises TypeError if not ValueGettable
- static get_value(widget: Any) Any[source]
Get value from widget using explicit ABC check.
- Parameters:
widget – The widget to get value from
- Returns:
The widget’s current value
- Raises:
TypeError – If widget doesn’t implement ValueGettable ABC
- static set_value(widget: Any, value: Any) None[source]
Set value on widget using explicit ABC check.
- Parameters:
widget – The widget to set value on
value – The value to set
- Raises:
TypeError – If widget doesn’t implement ValueSettable ABC
- static set_placeholder(widget: Any, text: str) None[source]
Set placeholder using explicit ABC check.
- Parameters:
widget – The widget to set placeholder on
text – The placeholder text
- Raises:
TypeError – If widget doesn’t implement PlaceholderCapable ABC
- static configure_range(widget: Any, minimum: float, maximum: float) None[source]
Configure range using explicit ABC check.
- Parameters:
widget – The widget to configure
minimum – Minimum value
maximum – Maximum value
- Raises:
TypeError – If widget doesn’t implement RangeConfigurable ABC
- static set_enum_options(widget: Any, enum_type: type) None[source]
Set enum options using explicit ABC check.
- Parameters:
widget – The widget to configure
enum_type – The Enum class
- Raises:
TypeError – If widget doesn’t implement EnumSelectable ABC
- static get_selected_enum(widget: Any) Any[source]
Get selected enum using explicit ABC check.
- Parameters:
widget – The widget to get selection from
- Returns:
The selected enum value
- Raises:
TypeError – If widget doesn’t implement EnumSelectable ABC
- static connect_change_signal(widget: Any, callback: Callable[[Any], None]) None[source]
Connect change signal using explicit ABC check.
- Parameters:
widget – The widget to connect signal on
callback – Callback function receiving new value
- Raises:
TypeError – If widget doesn’t implement ChangeSignalEmitter ABC
- static disconnect_change_signal(widget: Any, callback: Callable[[Any], None]) None[source]
Disconnect change signal using explicit ABC check.
- Parameters:
widget – The widget to disconnect signal from
callback – Callback function to disconnect
- Raises:
TypeError – If widget doesn’t implement ChangeSignalEmitter ABC