Skip to content

Conversation

@QuantumManiac
Copy link
Contributor

@QuantumManiac QuantumManiac commented Jan 14, 2026

#111 added a bunch of typing to the codebase. The typing that it added for mutable containers such as lists or dicts were too strict because many type checkers treat these containers as type-invariant, meaning that e.g. a value of type list[str] or list[bytes] is not permitted for an arg of type list[str | bytes]; Only a value of that exact type is.

The solution to this is to make use of abstract collections like Mapping and Sequence which are type covariant and therefore allow the above to work.

Note that for Mapping, only the values are type covariant and the keys are still type invariant and therefore e.g. dict[str | bytes, str | bytes] will need to be modified to Mapping[str, str | bytes] | Mapping[bytes, str | bytes] and not just Mapping[str | bytes, str | bytes]

also modified the env arg in pystemd.run.run() to copy the dict before mutating it so that the Mapping typing can be used.

@QuantumManiac QuantumManiac marked this pull request as ready for review January 14, 2026 03:43
@aleivag aleivag merged commit 6daf837 into systemd:main Jan 14, 2026
12 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants