* Run pytest in parallel with pytest-xdist
CI executes the full pytest suite serially, which currently takes
around 4-5 minutes. Most of that time is spent in fixture setup
(D-Bus session, mock services, CoreSys construction) rather than the
test bodies, but each test pays this setup cost on its own worker.
Add pytest-xdist and run with -n auto --dist=loadfile so tests are
distributed across CPU cores while keeping all tests of a file on the
same worker (preserves locality and keeps progress output readable).
GitHub Actions standard runners ship 4 vCPUs, so -n auto picks 4
workers in CI; locally on 8-core machines it picks 8. This matches
the pattern Home Assistant Core has been running for a long time
(--numprocesses auto --dist=loadfile in core's pytest-full job),
so the configuration is already battle-tested in a sibling project.
On an 8-core machine this cuts the local run from ~280s to ~88s
(~3.2x); on the 4-vCPU CI runner expect roughly a ~2x reduction.
The dbus-daemon and other session-scoped fixtures are spawned per
worker, so there is no shared state. pytest-cov already handles xdist
worker coverage merging via the standard .coverage.* files.
* Poll for resolution state in datadisk signal tests
test_multiple_datadisk_add_remove_signals and
test_disabled_datadisk_add_remove_signals fire UDisks2
InterfacesAdded/InterfacesRemoved signals through the real session
dbus-daemon and then assert that supervisor's signal handler chain
has updated coresys.resolution.issues. Each assertion was preceded
by ``await udisks2_service.ping()`` (only confirms signal delivery)
and ``await asyncio.sleep(0.2)`` to let the chained async tasks
finish.
The 0.2 s margin was effectively only 0.1 s of slack:
DataDisk._udisks2_interface_added itself does
``await asyncio.sleep(0.1)`` internally to wait for
UDisks2._interfaces_added (a sibling subscriber on the same signal)
to finish updating the block-device cache before the check runs.
Under xdist parallelism on a 4-vCPU CI runner that 100 ms cushion
evaporates, and the assertion races the handler.
Bumping the test sleep would just kick the can. Instead, replace
the four ``sleep+assert`` sites with a small polling helper
(tests.common.wait_for) that re-checks the predicate every 10 ms
up to a 5 s deadline. The wait completes the moment the resolution
state matches, so the test stays fast on idle and is robust under
load — and the assertion's failure mode becomes a clear "predicate
did not become true within 5 s" instead of a value mismatch.
The product-code sleep inside _udisks2_interface_added is still a
real smell (handler ordering shouldn't depend on a fixed sleep)
but is left for a separate fix; this commit is scoped to the test.
* Drop obsolete eager_start type ignore in CoreSys.create_task
The asyncio.AbstractEventLoop.create_task signature only gained the
eager_start keyword in the 3.14 typeshed. Now that Supervisor targets
3.14, the inline # type: ignore is redundant; mypy --warn-unused-ignores
flags it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Drop redundant int | None casts in OS slot status parsing
SlotStatusDataType already declares size, installed.count, and
activated.count as NotRequired[int], so .get(...) returns int | None
directly. The cast(int | None, ...) wrappers were no-ops; mypy
--warn-redundant-casts flags them.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Drop unreachable scheduler else branch
_Task.interval is annotated float | time; the float|int isinstance
arm narrows to time on the else branch, making the prior elif and
the trailing _LOGGER.critical fallback dead code that mypy
--warn-unreachable flags. Collapse to a plain else for the time arm.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Initialize credentials before pull_image try block
If _get_credentials raises before assigning, the except DockerError
handler at line 380-382 references an unbound credentials local. Mypy
--enable-error-code=possibly-undefined flags this path. Initialize to
an empty dict beforehand so the unauthorized branch reads as "no
credentials known", matching the auth=credentials or None semantics on
the success path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Use for/else to bind repository_file before .exists() check
If FILE_SUFFIX_CONFIGURATION is ever empty the loop body never runs
and repository_file is referenced unbound. Mypy
--enable-error-code=possibly-undefined flags it. The duplicate
.exists() check after the loop was also redundant: every loop body
either breaks on a hit or falls through to a final miss. Restructure
as for/else so the "no candidate matched" case is handled directly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Make match statements exhaustive with explicit case _
mypy --enable-error-code=exhaustive-match flags match blocks that fall
through to a trailing return/raise without a wildcard arm. The
behaviour is unchanged; this just hoists the default into the match so
the compiler can verify all cases are handled and future enum
additions are caught.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Tighten mypy: warn-unreachable, redundant casts, unused ignores
Add a [tool.mypy] section so the existing
mypy --ignore-missing-imports supervisor invocation in CI now also
enforces:
warn_unreachable — flags dead code, e.g. else branches the
type system has already eliminated.
warn_redundant_casts — flags cast() calls whose target type
already matches the source.
warn_unused_ignores — flags # type: ignore comments that no
longer suppress anything (typeshed
updates make these accumulate silently).
exhaustive-match — flags match statements without a default
arm, so future enum additions surface
as type errors instead of silent
fallthroughs.
possibly-undefined — flags references to names whose binding
depends on a path that may not run
(e.g. for-loop variables when the
iterable is empty).
ignore_missing_imports moves into the config so future invocations
don't need the CLI flag, but the workflow command is left unchanged
to keep the cache key stable.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Disable import error codes instead of ignoring missing imports
Match the pattern used in Home Assistant Core's mypy config: use
disable_error_code = ["import-not-found", "import-untyped"] rather
than ignore_missing_imports. This drops the (now redundant)
--ignore-missing-imports flag from the CI invocation as well.
The semantics are equivalent for the five untyped third-party deps
(pyudev, log_rate_limit, pulsectl, cpe, atomicwrites), but expressed
as suppressing two specific error codes rather than disabling all
import resolution checks.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Use match/case for scheduler interval dispatch
Express the float-vs-time dispatch as a match statement rather than
isinstance chain. Mypy treats case int() | float() and case time() as
exhaustive over the float | time annotation, so the new
exhaustive-match check is satisfied without a wildcard arm — and any
future broadening of the type will surface here as a static error.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Hoist _get_credentials above pull_image try/finally
Per review feedback: _get_credentials only does dict reads against
internal config state and cannot raise DockerRegistryRateLimitExceeded
or aiodocker.DockerError, so it does not need to live inside the
try block. Lift it out, and place it before the bus listener
registration so a future raise site can't leak a stale listener
through the finally cycle.
This supersedes the earlier credentials: dict = {} initializer; the
local is now bound on every path that reaches the except handler.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Enumerate MountUsage members in container_where match
Replace the case _: catch-all with case MountUsage.BACKUP | None:.
The exhaustive-match check is designed to fire when the matched type
widens, so adding a new MountUsage member without deciding whether it
exposes a container path now produces a build error pointing at this
match. The wildcard form swallowed that question silently.
Behaviour unchanged: BACKUP and None still return None.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The CI workflow used a blanket `cancel-in-progress: true`, which makes
sense for PR runs (collapse to the latest commit) but means pushes to
`main` cancel each other when several PRs merge in quick succession.
There is no shared state between CI runs that would justify either
cancelling or serializing them — each run is independent — and we'd
rather see every commit on `main` get a full check.
Make the concurrency group unique per `run_id` for non-PR events so
pushes to `main` neither cancel nor queue, while PRs keep the existing
cancel-on-new-push behavior through the shared per-ref group.
CI and tox both passed ``--timeout=10`` explicitly, but a plain local
``pytest`` had no timeout — a hung asyncio task or stuck D-Bus signal
handler could stall a developer's run indefinitely while passing CI.
Move the timeout into ``[tool.pytest.ini_options]`` so it applies
everywhere (pytest auto-discovers ``pyproject.toml`` in the repo
root) and drop the now-redundant ``--timeout=10`` flags from
``ci.yaml`` and ``tox.ini``. The full suite already fits comfortably
under 10s per test, and ``@pytest.mark.timeout(N)`` remains
available for per-test overrides if a specific test ever needs more
headroom.
* Use Python 3.14(.3) in CI and base image
Update base image to the latest tag using Python 3.14.3 and update Python
version in CI workflows to 3.14.
With Python 3.14, backports.zstd is no longer necessary as it's now available
in the standard library.
* Update wheels ABI in the wheels builder to cp314
* Use explicit Python fix version in GH actions
Specify explicitly Python 3.14.3, as the setup-python action otherwise default
to 3.14.2 when 3.14.3, leading to different version in CI and in production.
* Update Python version references in pyproject.toml
* Fix all ruff quoted-annotation (UP037) errors
* Revert unquoting of DBus types in tests and ignore UP037 where needed
Use name and path parameters to explicitly download the coverage report
artifact. This fixes a behavioral change introduced with v5.0.0
ofactions/download-artifact.