Skip to content

Commit f365313

Browse files
fix: Move class attribute warnings from constructor to setter
Signed-off-by: Souta Kawahara <souta.kawahara@almalinux.org>
1 parent 0bdc6d6 commit f365313

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

cyclonedx/model/bom.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,7 @@ def __init__(
8787
self.properties = properties or []
8888
self.manufacturer = manufacturer
8989
self.lifecycles = lifecycles or []
90-
9190
self.manufacture = manufacture
92-
if manufacture:
93-
warn(
94-
'`bom.metadata.manufacture` is deprecated from CycloneDX v1.6 onwards. '
95-
'Please use `bom.metadata.component.manufacturer` instead.',
96-
DeprecationWarning)
9791

9892
@property
9993
@serializable.type_mapping(serializable.helpers.XsdDateTime)
@@ -214,6 +208,11 @@ def manufacture(self, manufacture: Optional[OrganizationalEntity]) -> None:
214208
@todo Based on https://github.com/CycloneDX/specification/issues/346,
215209
we should set this data on `.component.manufacturer`.
216210
"""
211+
if manufacture:
212+
warn(
213+
'`bom.metadata.manufacture` is deprecated from CycloneDX v1.6 onwards. '
214+
'Please use `bom.metadata.component.manufacturer` instead.',
215+
DeprecationWarning)
217216
self._manufacture = manufacture
218217

219218
@property

cyclonedx/model/component.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,12 +1035,6 @@ def __init__(
10351035
self.crypto_properties = crypto_properties
10361036
self.tags = tags or []
10371037

1038-
if modified:
1039-
warn('`.component.modified` is deprecated from CycloneDX v1.3 onwards. '
1040-
'Please use `@.pedigree` instead.', DeprecationWarning)
1041-
if author:
1042-
warn('`.component.author` is deprecated from CycloneDX v1.6 onwards. '
1043-
'Please use `@.authors` or `@.manufacturer` instead.', DeprecationWarning)
10441038

10451039
@property
10461040
@serializable.type_mapping(_ComponentTypeSerializationHelper)
@@ -1175,6 +1169,9 @@ def author(self) -> Optional[str]:
11751169

11761170
@author.setter
11771171
def author(self, author: Optional[str]) -> None:
1172+
if author:
1173+
warn('`.component.author` is deprecated from CycloneDX v1.6 onwards. '
1174+
'Please use `@.authors` or `@.manufacturer` instead.', DeprecationWarning)
11781175
self._author = author
11791176

11801177
@property
@@ -1450,6 +1447,9 @@ def modified(self) -> bool:
14501447

14511448
@modified.setter
14521449
def modified(self, modified: bool) -> None:
1450+
if modified:
1451+
warn('`.component.modified` is deprecated from CycloneDX v1.3 onwards. '
1452+
'Please use `@.pedigree` instead.', DeprecationWarning)
14531453
self._modified = modified
14541454

14551455
@property

0 commit comments

Comments
 (0)