Skip to content

Tidy up the last few Ruff problems in one_shot.py#160

Open
rswarbrick wants to merge 1 commit intolowRISC:masterfrom
rswarbrick:one-shot-ruff-tweaks
Open

Tidy up the last few Ruff problems in one_shot.py#160
rswarbrick wants to merge 1 commit intolowRISC:masterfrom
rswarbrick:one-shot-ruff-tweaks

Conversation

@rswarbrick
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
"""Simple one-shot build flow for non-simulation targets like linting, synthesis and FPV."""

ignored_wildcards = [*FlowCfg.ignored_wildcards, "build_mode", "index", "test"]
ignored_wildcards: ClassVar[list[str]] = [
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.

Aside (you don't need to change it in this PR, it just came to mind as I looked at the code):

It needs a more careful examination, but it looks to me like FlowCfg.ignored_wildcards is only used in its _expand stage (with the HJSON __dict__ replacement magic). That is, I think this class attribute is set once and never mutated (even by the HJSON). If that is the case then this should probably be converted to a ClassVar[tuple[str, ...]] to remove the mutability. Either way the ClassVar type is reasonable here.


def __init__(self, flow_cfg_file, hjson_data, args, mk_config) -> None:
def __init__(
self, flow_cfg_file: str, hjson_data: Mapping, args: object, mk_config: Callable
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.

Nit: more specific types here?

Suggested change
self, flow_cfg_file: str, hjson_data: Mapping, args: object, mk_config: Callable
self, flow_cfg_file: str, hjson_data: Mapping[str, Any], args: argparse.Namespace, mk_config: Callable[[str], FlowCfg]

super().__init__(flow_cfg_file, hjson_data, args, mk_config)

def _merge_hjson(self, hjson_data) -> None:
def _merge_hjson(self, hjson_data: Mapping) -> None:
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.

Suggested change
def _merge_hjson(self, hjson_data: Mapping) -> None:
def _merge_hjson(self, hjson_data: Mapping[str, Any]) -> None:

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