Use UnitOfRatio.PARTS_PER_MILLION over deprecated CONCENTRATION_PARTS_PER_MILLION - #147
Open
jasonjhofmann wants to merge 2 commits into
Open
Use UnitOfRatio.PARTS_PER_MILLION over deprecated CONCENTRATION_PARTS_PER_MILLION#147jasonjhofmann wants to merge 2 commits into
jasonjhofmann wants to merge 2 commits into
Conversation
aiohttp 3.13 added a required keyword-only `stream_writer` argument to
`ClientResponse.__init__`. aioresponses (through 0.7.9, current) does not
pass it, so every mocked request in tests/test_client.py fails with:
TypeError: ClientResponse.__init__() missing 1 required
keyword-only argument: 'stream_writer'
This is latent on the current CI pin (Python 3.13 resolves an older aiohttp)
but surfaces as 52 failures the moment the runtime moves forward.
Defaults the kwarg in a new tests/conftest.py rather than capping the
test-time aiohttp, since requirements.txt is uncapped and pinning the tests
would mean never exercising the aiohttp users actually install. The shim is
self-limiting in both directions: on aiohttp<3.13 the parameter does not
exist and patching is skipped, and once aioresponses passes stream_writer
itself the setdefault becomes a no-op.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Home Assistant deprecated CONCENTRATION_PARTS_PER_MILLION in core#175189
(2026.8); it is removed in HA Core 2027.8. Running 2026.8.x, the integration
logs on every start:
The deprecated constant CONCENTRATION_PARTS_PER_MILLION was used from
ac_infinity. It will be removed in HA Core 2027.8. Use
UnitOfRatio.PARTS_PER_MILLION instead, please report it to the author of
the 'ac_infinity' custom integration
The replacement enum member has a byte-identical value ('ppm'), so no unit
string, entity state or stored statistic changes.
UnitOfRatio first exists in HA 2026.7.0 (absent in 2026.6.0), and HA 2026.7
requires Python >= 3.14.2. Two coupled changes follow:
- hacs.json gains "homeassistant": "2026.7.0". Without it HACS would offer
this version to users on older cores, where the import raises ImportError
at setup.
- quality.yaml moves 3.13 -> 3.14. requirements.txt installs homeassistant
unpinned, so on 3.13 pip resolves the newest HA that still supports 3.13
(2026.2.x), which predates UnitOfRatio and cannot exercise this code.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
On Home Assistant 2026.8.x the integration logs this on every start:
CONCENTRATION_PARTS_PER_MILLIONwas deprecated in core#175189 and is removed in HA Core 2027.8. This swaps the two uses (SensorType.CO2andSensorType.HYDRO_TDS_PPM) toUnitOfRatio.PARTS_PER_MILLION.The enum member's value is byte-identical (
"ppm"), so no unit string, entity state, or recorded statistic changes — the deprecated constant is already just an alias for it.Why this needs a version floor
UnitOfRatiofirst exists in HA 2026.7.0 (I checkedhomeassistant/const.pyat the release tags — it is absent at 2026.6.0). HA 2026.7 in turn declaresrequires-python = ">=3.14.2". Two consequences, both handled here:1.
hacs.jsongains"homeassistant": "2026.7.0". The repo currently declares no floor, so without this HACS would offer the update to users on older cores, where the import raisesImportErrorat setup.2.
quality.yamlmoves Python 3.13 → 3.14. This one is not cosmetic.requirements.txtinstallshomeassistantunpinned, so on 3.13 pip resolves the newest core that still supports 3.13 — which predatesUnitOfRatio:Without the bump, CI would go red on this PR for that reason alone.
The first commit is a prerequisite, and is independently useful
Moving CI to 3.14 pulls in a modern
aiohttp, which surfaces 52 failures intests/test_client.pythat have nothing to do with this change:aiohttp3.13 added a required keyword-onlystream_writertoClientResponse.__init__, andaioresponses(through 0.7.9, current) does not pass it. It is latent today only because the CI pin holdsaiohttpback. The first commit adds atests/conftest.pyshim that defaults the kwarg, rather than capping the test-timeaiohttp— pinning the tests would mean never exercising theaiohttpyour users actually install. It is self-limiting in both directions: onaiohttp<3.13the parameter does not exist and patching is skipped, and onceaioresponsespassesstream_writeritself thesetdefaultbecomes a no-op.It is a separate commit so you can take it on its own, or drop it if you would rather pin.
Verification
Measured on this branch, so the migration's effect is isolated:
mainmainstream_writer)main+ conftest shimThe last two rows are identical, so the unit migration itself introduces no test change. The 252 → 251 difference between rows 1 and 3 is the HA version jump (2026.2.3 → 2026.8.1), not either commit here.
One note in fairness: there is a large, constant count of
RuntimeError: There is no current event loop in thread 'MainThread'teardown errors in my local runs, present identically on unmodifiedmain. They look environmental and I did not chase them, but I did not want to quietly omit them — they are unchanged by this PR.Happy to drop the
hacs.jsonfloor or the CI bump into a separate PR, or adjust anything here, if you would prefer a different shape.