Explicitly give types to some fields in Deploy subclasses#154
Draft
rswarbrick wants to merge 3 commits intolowRISC:masterfrom
Draft
Explicitly give types to some fields in Deploy subclasses#154rswarbrick wants to merge 3 commits intolowRISC:masterfrom
rswarbrick wants to merge 3 commits intolowRISC:masterfrom
Conversation
The code in the constructor actually depends on lots of fields that are only in SimCfg, but we aren't really type-safe yet, so only find this out at runtime (when we try to do something other than a simulation). Correct the type safety at the site where we actually create the Deploy object. Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
These are: CompileSim, RunTest and CovReport. The types reflect what we are already doing. Taking CompileSim as an example, the stricter type is even reflected in the type of CompileSim.new. Take a spare copy of the object, but with a tighter type, to convince the type checker that we have indeed got what we think. Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
These get loaded from hjson in the superclass constructor, and the list created in _define_attrs ensures at runtime that they all exist. Put variables in to the constructor to teach the type-checker that they exist. Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
5365a52 to
0dd22d6
Compare
This was referenced Apr 2, 2026
AlexJones0
approved these changes
Apr 2, 2026
Contributor
AlexJones0
left a comment
There was a problem hiding this comment.
LGTM, since we already have runtime presence checks in _define_attrs. Ideally these would be validated on some explicit Pydantic model / dataclass in the future, but this is definitely a step in the right direction!
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.
NOTE: This is in draft because it depends on #144 and #153, which are the first two commits of the PR
These get loaded from hjson in the superclass constructor, and the list created in _define_attrs ensures at runtime that they all exist. Put variables in to the constructor to teach the type-checker that they exist.