feat(service): add ServiceInterface.add_property for runtime registration#639
feat(service): add ServiceInterface.add_property for runtime registration#639bluetoothbot wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #639 +/- ##
==========================================
+ Coverage 88.53% 88.71% +0.18%
==========================================
Files 29 29
Lines 3488 3544 +56
Branches 602 619 +17
==========================================
+ Hits 3088 3144 +56
Misses 248 248
Partials 152 152 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
ci is failing |
PR Review — feat(service): add ServiceInterface.add_property for runtime registrationThe feature itself is well-shaped: a single new public method on The blocker is real and surfaced by CI: The Secondary items: 🔴 Blocking1. Cython argument type-checks bypass manual TypeError messages, breaking tests (`src/dbus_fast/service.py`, L544-551)On every When The symmetric module-level
Option 1 is the right fix: it keeps the human-readable error messages, matches the rest of the file's pattern, and is what fails the use_cython CI matrix today. 🟡 Important1. `_make_dynamic` bypasses `_Property.__init__` and will drift (`src/dbus_fast/service.py`, L348-374)
Consider factoring the field initialisation out of 🟢 Suggestions1. `__dict__["_dynamic"]` is heavier than needed (`src/dbus_fast/service.py`, L373)
Not blocking, but worth doing while the code is still fresh. 2. Duplicate-name check is not atomic under free-threading (`src/dbus_fast/service.py`, L631-637)The matrix includes Under free-threading, two concurrent It's reasonable to declare 3. `inspect.iscoroutinefunction(None)` on write-only dynamic property (`src/dbus_fast/service.py`, L834-837)For a dynamic property created with only a setter ( In practice the bus layer at Checklist
SummaryThe feature itself is well-shaped: a single new public method on The blocker is real and surfaced by CI: The Secondary items: |
The CI failure is consistent across every With Fix is to either drop the strict annotations on the public method (the pattern The |
…tion Lets callers register a DBus property at runtime by passing plain getter/setter callables. The property is exposed via introspection and the standard Properties interface alongside decorator-defined members. Resolves #612.
Rebase with requested adjustmentsBranch StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
d7f2cf0 to
00b67dc
Compare
What
Add a public
ServiceInterface.add_property()method so DBus properties can be registered at runtime by passing plain getter and setter callables.Why
Resolves #612. Today properties can only be declared via the
@dbus_propertyclass decorator. That means the property set must be known at class-definition time, which doesn't fit services that derive their property catalog from external configuration, a database, or other runtime input.How
ServiceInterface.add_property(name, signature, getter=, setter=, access=, disabled=)builds a_Propertyvia a private_Property._make_dynamicconstructor that bypasses decorator-only setup and registers the property on the instance._get_property_value/_set_property_valuenow invoke the stored callable directly when the property is dynamic, instead of going throughgetattr(instance, getter.__name__)(which can't work for non-method callables). Class-defined properties keep the existing descriptor path.assert_member_name_valid/get_signature_treevalidators.emit_properties_changed,introspect(), and the standardPropertiesinterface all use_get_properties, so dynamic properties light up automatically.Testing
tests/service/test_add_property.pycover sync/async getter+setter, inferred and explicit access modes, duplicate-name and bad-signature/name rejection, type-error guards, coexistence with decorator-defined properties, callback-routed exceptions, andemit_properties_changedfor dynamic props.tests/service/+ introspection/marshaller/signature/validator suites pass (the bus-dependent testsPermissionErrorlocally; that's unchanged).Quality Report
Changes: 3 files changed, 477 insertions(+), 4 deletions(-)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline