Skip to content

Commit 57767f7

Browse files
committed
feat: convert to cattrs
All tests pass
1 parent 586edc2 commit 57767f7

706 files changed

Lines changed: 14879 additions & 19039 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cyclonedx/model/__init__.py

Lines changed: 248 additions & 804 deletions
Large diffs are not rendered by default.

cyclonedx/model/bom.py

Lines changed: 560 additions & 496 deletions
Large diffs are not rendered by default.

cyclonedx/model/bom_ref.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,14 @@
1818

1919
from typing import TYPE_CHECKING, Any, Optional
2020

21-
import py_serializable as serializable
22-
2321
from ..exception.serialization import CycloneDxDeserializationException, SerializationOfUnexpectedValueException
2422

2523
if TYPE_CHECKING: # pragma: no cover
2624
from typing import TypeVar
27-
2825
_T_BR = TypeVar('_T_BR', bound='BomRef')
2926

3027

31-
@serializable.serializable_class(ignore_unknown_during_deserialization=True)
32-
class BomRef(serializable.helpers.BaseHelper):
28+
class BomRef:
3329
"""
3430
An identifier that can be used to reference objects elsewhere in the BOM.
3531
@@ -40,11 +36,10 @@ class BomRef(serializable.helpers.BaseHelper):
4036
"""
4137

4238
def __init__(self, value: Optional[str] = None) -> None:
43-
self.value = value
39+
# empty strings become `None`
40+
self._value = value or None
4441

4542
@property
46-
@serializable.json_name('.')
47-
@serializable.xml_name('.')
4843
def value(self) -> Optional[str]:
4944
return self._value
5045

@@ -80,8 +75,6 @@ def __str__(self) -> str:
8075
def __bool__(self) -> bool:
8176
return self._value is not None
8277

83-
# region impl BaseHelper
84-
8578
@classmethod
8679
def serialize(cls, o: Any) -> Optional[str]:
8780
if isinstance(o, cls):
@@ -97,5 +90,3 @@ def deserialize(cls: 'type[_T_BR]', o: Any) -> '_T_BR':
9790
raise CycloneDxDeserializationException(
9891
f'BomRef string supplied does not parse: {o!r}'
9992
) from err
100-
101-
# endregion impl BaseHelper

0 commit comments

Comments
 (0)