Add bronze quality scale to DNS IP#169688
Add bronze quality scale to DNS IP#169688Phil-Rad wants to merge 4 commits intohome-assistant:devfrom
Conversation
|
Hey there @gjohansson-ST, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
This pull request brings the dnsip integration onto the Home Assistant Integration Quality Scale by declaring Bronze compliance and aligning metadata/translations accordingly.
Changes:
- Add
homeassistant/components/dnsip/quality_scale.yamlwith Bronze rules markeddone/exempt(and higher tiers left astodo). - Declare
"quality_scale": "bronze"in thednsipintegration manifest. - Update
dnsiptranslations to usedata_descriptionhelper text for config/options flows and removednsipfrom hassfest “without quality scale” lists.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| script/hassfest/quality_scale.py | Removes dnsip from lists that track integrations lacking IQS grading/files. |
| homeassistant/components/dnsip/strings.json | Moves verbose field help text into data_description and keeps concise labels in data. |
| homeassistant/components/dnsip/quality_scale.yaml | Adds the quality scale rule audit and Bronze tier declaration for dnsip. |
| homeassistant/components/dnsip/manifest.json | Sets the integration’s declared quality scale tier to bronze. |
| status: exempt | ||
| comment: Each WanIpSensor manages its own aiodns.DNSResolver instance and there is no shared state at the config-entry level. | ||
| test-before-configure: done | ||
| test-before-setup: |
There was a problem hiding this comment.
We should probably fix that beforehand instead of exempting it.
We can create the resolver in setup, test the connection and attach it to config entry runtime to use later in the sensor (I don't see a need for a coordinator really)
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
First commit so just wanted something small to see how it works but now done with your request and pushed the refactor.
All local checks green. Let me know if something else needs to be changed. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
tests/components/dnsip/test_init.py:55
- Add assertions/tests to cover the new setup-time validation and ensure resolver resources are properly closed on unload and on setup failure.
entry.add_to_hass(hass)
with patch(
"homeassistant.components.dnsip.aiodns.DNSResolver",
return_value=RetrieveDNS(),
):
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
| resolver_ipv4 = aiodns.DNSResolver( | ||
| nameservers=[nameserver_ipv4], tcp_port=port_ipv4, udp_port=port_ipv4 | ||
| ) | ||
| resolver_ipv6 = aiodns.DNSResolver( | ||
| nameservers=[nameserver_ipv6], tcp_port=port_ipv6, udp_port=port_ipv6 | ||
| ) | ||
|
|
||
| hostname = entry.data[CONF_HOSTNAME] | ||
| try: | ||
| async with asyncio.timeout(10): | ||
| if entry.data[CONF_IPV4]: | ||
| await resolver_ipv4.query(hostname, "A") | ||
| elif entry.data[CONF_IPV6]: | ||
| await resolver_ipv6.query(hostname, "AAAA") | ||
| except (TimeoutError, DNSError) as err: | ||
| raise ConfigEntryNotReady(f"DNS lookup failed for {hostname}: {err}") from err |
| try: | ||
| async with asyncio.timeout(10): | ||
| if entry.data[CONF_IPV4]: | ||
| await resolver_ipv4.query(hostname, "A") | ||
| elif entry.data[CONF_IPV6]: | ||
| await resolver_ipv6.query(hostname, "AAAA") | ||
| except (TimeoutError, DNSError) as err: | ||
| raise ConfigEntryNotReady(f"DNS lookup failed for {hostname}: {err}") from err | ||
|
|
There was a problem hiding this comment.
Unsure if this is required. Can add this change if this is needed
| async def async_unload_entry(hass: HomeAssistant, entry: DnsIPConfigEntry) -> bool: | ||
| """Unload DNS IP config entry.""" | ||
|
|
||
| return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) |
| dns_mock.error = DNSError() | ||
| with patch( | ||
| "homeassistant.components.dnsip.sensor.aiodns.DNSResolver", | ||
| "homeassistant.components.dnsip.aiodns.DNSResolver", | ||
| return_value=dns_mock, | ||
| ): |
| with ( | ||
| patch( | ||
| "homeassistant.components.dnsip.sensor.aiodns.DNSResolver", | ||
| "homeassistant.components.dnsip.aiodns.DNSResolver", | ||
| return_value=dns_mock, | ||
| ), |
| runtime-data: done | ||
| test-before-configure: done | ||
| test-before-setup: done | ||
| unique-config-entry: done |
| try: | ||
| async with asyncio.timeout(10): | ||
| if entry.data[CONF_IPV4]: | ||
| await resolver_ipv4.query(hostname, "A") | ||
| elif entry.data[CONF_IPV6]: | ||
| await resolver_ipv6.query(hostname, "AAAA") | ||
| except (TimeoutError, DNSError) as err: | ||
| await resolver_ipv4.close() | ||
| await resolver_ipv6.close() | ||
| raise ConfigEntryNotReady(f"DNS lookup failed for {hostname}: {err}") from err | ||
|
|
| resolver_ipv6=resolver_ipv6, | ||
| ) | ||
|
|
||
| await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) |
Breaking change
Proposed change
Brings the
dnsipintegration onto the Integration Quality Scale at the Bronze tier.Changes:
homeassistant/components/dnsip/quality_scale.yaml— full rule audit against the Bronze checklist; all 18 Bronze rules satisfied (doneorexemptwith justification). Silver / Gold / Platinum rules left astodofor follow-up PRs.manifest.json— added"quality_scale": "bronze".strings.json— addeddata_descriptionblocks under bothconfig.step.userandoptions.step.init. The existing descriptive text was promoted fromdata(field labels) todata_description(helper text), with concise field names retained as labels. This is required by the strict translation check that activates onceconfig-flow: doneis claimed.script/hassfest/quality_scale.py— removeddnsipfrom bothINTEGRATIONS_WITHOUT_QUALITY_SCALE_FILEandINTEGRATIONS_WITHOUT_SCALE.Two Bronze rules are marked
exemptrather thandone, which I'd appreciate a sanity check on:runtime-data— eachWanIpSensorcarries its ownaiodns.DNSResolverinstance. There is no shared per-config-entry state that benefits from being stored onentry.runtime_data.test-before-setup— the integration has no central connection to validate at setup time. Each sensor performs its own DNS resolution inasync_updateand reports availability via_attr_available.Happy to refactor toward a
DataUpdateCoordinatorpattern in a follow-up if you'd prefer those rules to bedonerather thanexempt. Wanted to keep this PR scoped to the YAML / strings changes for clean review.Validated locally:
python -m script.hassfest --integration-path homeassistant/components/dnsip— cleanpytest tests/components/dnsip/— 17 passedruff check— cleanType of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: