docs: fix invalid custom-domain quick-start example (#88)#95
Merged
Conversation
The quick-start re-registered the built-in 'fan' domain, which raises HAClientError on import. Replace with a non-conflicting 'sprinkler' example and update the generic-accessor snippet to call the real set_percentage() method instead of the nonexistent set_speed(). Add a regression test that execs the documented snippet against an isolated DomainRegistry, so any future drift between docs and the public API fails CI.
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.
Closes #88.
Validity assessment
Valid and actionable. Verified both claims directly against the source:
docs/index.mdregistered afanDomainSpec, but the built-in fandomain is already registered at import time (
src/haclient/domains/fan.py:345,imported via
src/haclient/domains/__init__.py).DomainRegistry.registerrejects duplicate names for a different class
(
src/haclient/core/plugins.py:245-269), so the documented snippet raisedHAClientErrorimmediately on copy/paste.fan.set_speed(75). The real public method on thefan entity is
set_percentage()(src/haclient/domains/fan.py:244); noset_speedexists.Fix
sprinklerdomainand clarify that
_call_serviceis extension implementation code.fan.set_speed(75)snippet with a workingha.fan("ceiling").set_percentage(75)call.tests/test_plugins.py::test_docs_custom_domain_example_runs)that extracts the documented snippet and exec's it against an isolated
DomainRegistry. Any future drift between the docs and the public API(renamed helper, removed export, duplicate built-in) will now fail CI.
Checks run
pytest tests/ --cov=haclient --cov-report=term-missing --cov-fail-under=95→ 319 passed, coverage 97.18%.
ruff check src tests→ clean.ruff format --check src tests→ clean (after formatting the new test).mypy src→ no issues found in 38 source files.