Skip to content

boot-utils: Add type annotations and linting with ty#130

Merged
nathanchance merged 3 commits intoClangBuiltLinux:mainfrom
nathanchance:ty
Apr 8, 2026
Merged

boot-utils: Add type annotations and linting with ty#130
nathanchance merged 3 commits intoClangBuiltLinux:mainfrom
nathanchance:ty

Conversation

@nathanchance
Copy link
Copy Markdown
Member

See the individual changes for the full details.

NOTE: This requires ClangBuiltLinux/actions-workflows#12 to be effective.

We are going to be adding type annotations to boot-utils. There were
several changes to type annotations in Python 3.9 that are not
compatible with Python 3.8 and easier, such as list[str] instead of
List[str], so just drop support for Python 3.9. With a tool like uv, it
is easy to get a newer version of Python if necessary to run boot-utils.

With this bump, ruff formats a couple of files differently.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This allows us to use a type checker like ty [1] to help validate our
code.

For the most part, this is fairly mechanical. The one area that required
some reworking is the Path variables that were initially None, which
makes ty unhappy in many paths where a Path member in QEMURunner is not
obviously set. To make it easier on ty, create a special canary
variable with /uninitialized as its value to check if a Path variable
has not been properly set. This will allow it to standout at runtime if
a check was missed.

Link: https://docs.astral.sh/ty [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Now that we have added proper typing annotations, enable ty.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
@nathanchance nathanchance merged commit df4e2fe into ClangBuiltLinux:main Apr 8, 2026
6 checks passed
@nathanchance nathanchance deleted the ty branch April 8, 2026 22:31
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