Port read/write values data type improvements & more - #217
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request tightens value typing across the port subsystem by distinguishing readable values (which may be unavailable) from writable values (which must be concrete), and updates related drivers, virtual/slave ports, and API entry points accordingly.
Changes:
- Change multiple
write_value/write-queue entry points to acceptPortValue(non-nullable), while keeping reads asNullablePortValue. - Update expression-driven writes (
eval_and_push_write) to compare againstget_last_value()and adjust unit tests accordingly (including removal ofget_target_value()tests). - Adjust API “set port attrs” behavior to avoid attempting background writes when
"value": null.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/qtoggleserver/mock/ports.py | Updates mock port write_value signature to PortValue. |
| tests/unit/qtoggleserver/core/test_ports.py | Removes get_target_value() tests and updates expression-write tests to use get_last_value(). |
| qtoggleserver/slaves/ports.py | Updates slave port write_value signature to PortValue. |
| qtoggleserver/lib/polled.py | Updates _write_value_safe signature to PortValue for polled ports. |
| qtoggleserver/drivers/ports/gpio/gpio.py | Updates GPIO port read/write typing and removes nullable-write no-op behavior. |
| qtoggleserver/drivers/ports/gpio/dummy.py | Updates dummy GPIO port read/write typing to align with new PortValue writes. |
| qtoggleserver/drivers/ports/dummynumeric.py | Updates dummy numeric port read/write typing to align with new PortValue writes. |
| qtoggleserver/core/vports.py | Updates virtual port write_value signature to PortValue. |
| qtoggleserver/core/ports.py | Core refactor: removes get_target_value(), makes write paths non-nullable, tweaks expression write decision logic, and changes legacy persisted value handling. |
| qtoggleserver/core/api/funcs/ports.py | Avoids background writes for "value": null and aligns casts with PortValue. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.