Skip to content

Define a more strictly typed "sim_cfg" in some Deploy subclasses#153

Open
rswarbrick wants to merge 1 commit intolowRISC:masterfrom
rswarbrick:stricter-sim-cfg
Open

Define a more strictly typed "sim_cfg" in some Deploy subclasses#153
rswarbrick wants to merge 1 commit intolowRISC:masterfrom
rswarbrick:stricter-sim-cfg

Conversation

@rswarbrick
Copy link
Copy Markdown
Contributor

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.

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>
Comment on lines +381 to +382
# Register a copy of sim_cfg which is explicitly the SimCfg type
self._typed_sim_cfg: SimCfg = sim_cfg
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems reasonable - my personal preference for python is to use from __future__ import annotations and (long-term) to decouple the objects to resolve circular dependencies and fix these kinds of issues, but I guess we haven't done this for historical reasons (using older Python versions). This is a pragmatic workaround for the meantime.

Referring back to my comment on #144:

I wonder, would it not be a good idea to rename sim_cfg -> flow_cfg as well?

I think my preference would be to have the base Deploy etc. take a flow_cfg: "FlowCfg" and then have these deploys that only work for simulation flows take a sim_cfg: SimCfg. That way we can just have self.flow_cfg and perhaps self._sim_cfg instead of self._typed_sim_cfg. With the same explanatory comment above, I think that would probably help with readability.

Even better would be to use a property so it is inherently clear that one is derived from the other and we don't have duplicated references, but I think that would run into the same circular import issue for now.

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