Skip to content

Commit 1e32cf1

Browse files
committed
fix: mypy
1 parent 8885bf1 commit 1e32cf1

5 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/mobster/cmd/generate/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from spdx_tools.spdx.writer.write_anything import write_file
1010

1111
from mobster.cmd.base import Command
12-
from mobster.cmd.generate.oci_image.sbomgen import SBOMMetadata
1312

1413
LOGGER = logging.getLogger(__name__)
1514

@@ -21,7 +20,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
2120
super().__init__(*args, **kwargs)
2221

2322
self._content: Any = None
24-
self._metadata: SBOMMetadata | None = None
23+
self._metadata: Any = None
2524

2625
@property
2726
def content(self) -> Any:

src/mobster/cmd/generate/oci_image/sbomgen.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Dataclasses for parsing SBOM metadata files provided by sbomgen."""
22

33
from dataclasses import dataclass
4+
from typing import Any, Self
45

56
from mobster.error import SBOMError
67

@@ -13,7 +14,7 @@ class ImageData:
1314
digest: str
1415

1516
@classmethod
16-
def from_dict(cls, data: dict):
17+
def from_dict(cls, data: dict[str, str]) -> Self:
1718
"""Create a new ImageData from a dict."""
1819
try:
1920
pullspec = data["pullspec"]
@@ -37,7 +38,7 @@ class SBOMMetadata:
3738
extra_images: list[ImageData]
3839

3940
@classmethod
40-
def from_dict(cls, data: dict):
41+
def from_dict(cls, data: dict[str, Any]) -> Self:
4142
"""
4243
Create a new SBOMMetadata from a dict.
4344
(This also attempts to map any contained ImageData with

tests/cmd/generate/oci_image/test_module_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ async def test_GenerateOciImageCommand__handle_bom_inputs(
299299
mock_load_hermeto_sbom.return_value = mock_hermeto_data
300300
mock_merge.return_value = mock_merged_data
301301

302-
def mock_metadata():
302+
def mock_metadata() -> None:
303303
command._metadata = SBOMMetadata(
304304
image=ImageData(pullspec="foo", digest="bar"),
305305
base_images=[],

tests/integration/img_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def make_metadata_yaml(
2020
"base_images": [],
2121
}
2222
if parent_img:
23-
metadata["base_images"].append(
23+
metadata["base_images"].push( # type: ignore[attr-defined]
2424
{
2525
"pullspec": f"{parent_img.repository}:{parent_img.tag}",
2626
"digest": parent_img.digest,

tests/integration/test_tekton.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ def get_sbom_from_test_case(case: GenerateOciImageTestCase, image_digest: str) -
302302
Load an SBOM from a GenerateOciImageTestCase, replaces digests with
303303
specified and return it parsed to bytes.
304304
"""
305+
assert case.args.metadata_path is not None
305306
with open(case.expected_sbom_path) as fp, open(case.args.metadata_path) as md_fp:
306307
metadata = yaml.load(md_fp, Loader=yaml.Loader)
307308
digest_from_metadata = metadata["image"]["digest"]

0 commit comments

Comments
 (0)