Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 0.7.2

Requires `metaclass-registry>=0.4.0`, `objectstate>=3.0.1,<4`,
`formbridge>=0.1.3,<0.2` and `zmqruntime>=0.6.4,<0.7`.

Changed:

- A widget id names one widget class. Registering a different class under an
id that is already taken raises `ValueError`; it used to log a warning and
replace the first class. The same class statement run again (a reload)
takes its id back.
- A form output type has one builder: `InitializationServiceCatalog` raises
`ValueError` when a second builder declares an output type that already
has one.

## 0.7.1

Requires ObjectState 3 (`objectstate>=3.0,<4`) and `formbridge>=0.1.2,<0.2`.
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ keywords = ["pyqt6", "forms", "reactive", "gui", "widgets", "dataclass"]

dependencies = [
"annotated-types>=0.7.0",
"formbridge>=0.1.2,<0.2",
"formbridge>=0.1.3,<0.2",
"magicgui>=0.7.0",
"metaclass-registry>=0.1.5",
"metaclass-registry>=0.4.0",
"PyQt6>=6.4.0",
"objectstate>=3.0,<4",
"objectstate>=3.0.1,<4",
"psutil>=5.9",
"Pygments>=2.15",
"python-introspect>=0.2.6,<0.3",
"zmqruntime>=0.6,<0.7",
"zmqruntime>=0.6.4,<0.7",
]

[project.optional-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion requirements-ci.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Source candidates needed to validate this checkout before coordinated publication.
# Empty: every first-party dependency is released (objectstate 3.0.0, formbridge 0.1.2).
# Empty: every first-party dependency is released (objectstate 3.0.1,
# formbridge 0.1.3, zmqruntime 0.6.4, metaclass-registry 0.4.0).
2 changes: 1 addition & 1 deletion src/pyqt_reactive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- Cross-window reactive updates
"""

__version__ = "0.7.1"
__version__ = "0.7.2"

# Public API will be populated as modules are added
__all__ = [
Expand Down
5 changes: 5 additions & 0 deletions src/pyqt_reactive/forms/form_init_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ def __init__(self) -> None:
def builder_for(self, output_type: Type, service_name: str):
"""Decorator to register builder function and auto-generate service class."""
def decorator(func: Callable) -> Callable:
if output_type in self._builders_by_output:
raise ValueError(
f"{output_type.__qualname__} already has a builder "
f"({self._builders_by_output[output_type].service_name})."
)
self._builders_by_output[output_type] = BuilderSpec(output_type, service_name, func)
return func
return decorator
Expand Down
17 changes: 11 additions & 6 deletions src/pyqt_reactive/forms/widget_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ def __new__(cls, name, bases, attrs):
logger.debug(f"Skipping registration for {name} - no _widget_id attribute")
return new_class

# Check for duplicate registration
if widget_id in WIDGET_IMPLEMENTATIONS:
existing = WIDGET_IMPLEMENTATIONS[widget_id]
logger.warning(
f"Widget ID '{widget_id}' already registered to {existing.__name__}. "
f"Overwriting with {name}."
# A widget id names one widget class. The same class statement
# run again (a reload) takes its id back.
existing = WIDGET_IMPLEMENTATIONS.get(widget_id)
if existing is not None and (
existing.__module__ != new_class.__module__
or existing.__qualname__ != new_class.__qualname__
):
raise ValueError(
f"Widget ID '{widget_id}' is already registered to "
f"{existing.__module__}.{existing.__qualname__}; "
f"{new_class.__module__}.{new_class.__qualname__} cannot use it too."
)

# Auto-register in global registry
Expand Down
Loading