boot-utils: Add type annotations and linting with ty#130
Merged
nathanchance merged 3 commits intoClangBuiltLinux:mainfrom Apr 8, 2026
Merged
boot-utils: Add type annotations and linting with ty#130nathanchance merged 3 commits intoClangBuiltLinux:mainfrom
nathanchance merged 3 commits intoClangBuiltLinux:mainfrom
Conversation
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>
msfjarvis
approved these changes
Apr 8, 2026
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>
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.
See the individual changes for the full details.
NOTE: This requires ClangBuiltLinux/actions-workflows#12 to be effective.