Skip to content

Explicitly give types to some fields in Deploy subclasses#154

Draft
rswarbrick wants to merge 3 commits intolowRISC:masterfrom
rswarbrick:type-deploy-fields
Draft

Explicitly give types to some fields in Deploy subclasses#154
rswarbrick wants to merge 3 commits intolowRISC:masterfrom
rswarbrick:type-deploy-fields

Conversation

@rswarbrick
Copy link
Copy Markdown
Contributor

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.

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>
Copy link
Copy Markdown
Contributor

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

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