Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions badges/coverage-python.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions renovate.json

This file was deleted.

16 changes: 4 additions & 12 deletions siemens_standard_bom/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright (c) Siemens AG 2019-2025 ALL RIGHTS RESERVED
# SPDX-License-Identifier: MIT
#
import enum
from datetime import datetime
from enum import Enum
from importlib.metadata import version as library_version
Expand Down Expand Up @@ -153,10 +152,7 @@ def scope(self, value: ComponentScope) -> None:

@property
def authors(self) -> ImmutableList[OrganizationalContact]:
if self.component.authors is None:
authors = ImmutableList[OrganizationalContact]()
else:
authors = ImmutableList[OrganizationalContact](self.component.authors)
authors = ImmutableList[OrganizationalContact](self.component.authors or [])

# Backward compatibility with v2
if self.component.author is not None:
Expand Down Expand Up @@ -270,15 +266,15 @@ def filename(self, value: str) -> None:

@staticmethod
def get_custom_property(component: Optional[Component], custom_property_key: str) -> Optional[str]:
if component is not None and component.properties is not None and custom_property_key is not None:
if component is not None and component.properties is not None:
found = next(filter(lambda prop: prop.name == custom_property_key, component.properties), None)
if found:
return found.value
return None

@staticmethod
def set_custom_property(component: Optional[Component], custom_property_key: str, value: str) -> None:
if component is not None and component.properties is not None and custom_property_key is not None:
if component is not None and component.properties is not None:
found = next(filter(lambda prop: prop.name == custom_property_key, component.properties), None)
if found:
found.value = value
Expand Down Expand Up @@ -516,7 +512,7 @@ class SbomNature(str, Enum):
BINARY = "binary"

def __new__(cls, value: object, *args: Any, **kwargs: Any) -> 'SbomNature':
if not isinstance(value, (str, enum.auto)):
if not isinstance(value, str):
raise TypeError(
f"Values of StrEnums must be strings: {value!r} is a {type(value)}"
)
Expand All @@ -526,10 +522,6 @@ def __str__(self) -> str:
return str(self.value)


def is_valid_serial_number(serial_number: str | None) -> bool:
return not (serial_number is None or "urn:uuid:None" == serial_number)


def is_standardbom_component_entry(component: Component) -> bool:
return component.supplier is not None \
and component.supplier.name == 'Siemens AG' \
Expand Down
9 changes: 6 additions & 3 deletions tests/test_immutable_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ def test_immutable_items_attribute(self) -> None:
il.__setattr__('_items', 10)

def test_immutable_length(self) -> None:
il = ImmutableList(1, 2, 3, 4, 5)
with self.assertRaises(FrozenInstanceError):
il.__setattr__('_length', 10)
items = [1, 2, 3, 4, 5]
il = ImmutableList[int](items)

items.append(6)

self.assertEqual(len(il), 5)

def test_map_values_from_a_tuple(self) -> None:
values = (1, 2, 3, 4, 5)
Expand Down
Loading