Skip to content

Commit 84811d0

Browse files
committed
better naming
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent 0df19fa commit 84811d0

5 files changed

Lines changed: 28 additions & 25 deletions

File tree

cyclonedx/model/bom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from .._internal.compare import ComparableTuple as _ComparableTuple
3131
from .._internal.time import get_now_utc as _get_now_utc
3232
from ..exception.model import LicenseExpressionAlongWithOthersException, UnknownComponentDependencyException
33-
from ..schema.deprecation import DeprecationWarning1Dot6
33+
from ..schema.deprecation import SchemaDeprecationWarning1Dot6
3434
from ..schema.schema import (
3535
SchemaVersion1Dot0,
3636
SchemaVersion1Dot1,
@@ -292,7 +292,7 @@ def manufacture(self, manufacture: Optional[OrganizationalEntity]) -> None:
292292
we should set this data on `.component.manufacturer`.
293293
"""
294294
if manufacture is not None:
295-
DeprecationWarning1Dot6._warn('bom.metadata.manufacture', 'bom.metadata.component.manufacturer')
295+
SchemaDeprecationWarning1Dot6._warn('bom.metadata.manufacture', 'bom.metadata.component.manufacturer')
296296
self._manufacture = manufacture
297297

298298
@property

cyclonedx/model/component.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
SerializationOfUnexpectedValueException,
4141
SerializationOfUnsupportedComponentTypeException,
4242
)
43-
from ..schema.deprecation import DeprecationWarning1Dot3, DeprecationWarning1Dot6
43+
from ..schema.deprecation import (
44+
SchemaDeprecationWarning1Dot3,
45+
SchemaDeprecationWarning1Dot6,
46+
)
4447
from ..schema.schema import (
4548
SchemaVersion1Dot0,
4649
SchemaVersion1Dot1,
@@ -1186,7 +1189,7 @@ def author(self) -> Optional[str]:
11861189
@author.setter
11871190
def author(self, author: Optional[str]) -> None:
11881191
if author is not None:
1189-
DeprecationWarning1Dot6._warn('@.author', '@.authors` or `@.manufacturer')
1192+
SchemaDeprecationWarning1Dot6._warn('@.author', '@.authors` or `@.manufacturer')
11901193
self._author = author
11911194

11921195
@property
@@ -1467,7 +1470,7 @@ def modified(self) -> bool:
14671470
@modified.setter
14681471
def modified(self, modified: bool) -> None:
14691472
if modified:
1470-
DeprecationWarning1Dot3._warn('@.modified', '@.pedigree')
1473+
SchemaDeprecationWarning1Dot3._warn('@.modified', '@.pedigree')
14711474
self._modified = modified
14721475

14731476
@property

cyclonedx/model/tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from .._internal.compare import ComparableTuple as _ComparableTuple
2929
from ..schema import SchemaVersion
30-
from ..schema.deprecation import DeprecationWarning1Dot5
30+
from ..schema.deprecation import SchemaDeprecationWarning1Dot5
3131
from ..schema.schema import SchemaVersion1Dot4, SchemaVersion1Dot5, SchemaVersion1Dot6, SchemaVersion1Dot7
3232
from . import ExternalReference, HashType, _HashTypeRepositorySerializationHelper
3333
from .component import Component
@@ -240,7 +240,7 @@ def tools(self) -> 'SortedSet[Tool]':
240240
@tools.setter
241241
def tools(self, tools: Iterable[Tool]) -> None:
242242
if tools:
243-
DeprecationWarning1Dot5._warn('@.tools', '@.components` and `@.services')
243+
SchemaDeprecationWarning1Dot5._warn('@.tools', '@.components` and `@.services')
244244
self._tools = SortedSet(tools)
245245

246246
def __len__(self) -> int:

cyclonedx/schema/deprecation.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323

2424
__all__ = [
2525
'SchemaDeprecationWarning',
26-
'DeprecationWarning1Dot1',
27-
'DeprecationWarning1Dot2',
28-
'DeprecationWarning1Dot3',
29-
'DeprecationWarning1Dot4',
30-
'DeprecationWarning1Dot5',
31-
'DeprecationWarning1Dot6',
32-
'DeprecationWarning1Dot7',
26+
'SchemaDeprecationWarning1Dot1',
27+
'SchemaDeprecationWarning1Dot2',
28+
'SchemaDeprecationWarning1Dot3',
29+
'SchemaDeprecationWarning1Dot4',
30+
'SchemaDeprecationWarning1Dot5',
31+
'SchemaDeprecationWarning1Dot6',
32+
'SchemaDeprecationWarning1Dot7',
3333
]
3434

3535

36-
class SchemaDeprecationWarning(DeprecationWarning, ABC):
36+
class BaseSchemaDeprecationWarning(DeprecationWarning, ABC):
3737
"""Base class for warnings about deprecated schema features."""
3838

3939
SCHEMA_VERSION: ClassVar[SchemaVersion]
@@ -47,36 +47,36 @@ def _warn(cls, deprecated: str, instead: Optional[str] = None, *, stacklevel: in
4747
warn(msg, category=cls, stacklevel=stacklevel + 1)
4848

4949

50-
class DeprecationWarning1Dot7(SchemaDeprecationWarning):
50+
class SchemaDeprecationWarning1Dot7(BaseSchemaDeprecationWarning):
5151
"""Class for warnings about deprecated schema features in CycloneDX 1.7"""
5252
SCHEMA_VERSION: ClassVar[Literal[SchemaVersion.V1_7]] = SchemaVersion.V1_7
5353

5454

55-
class DeprecationWarning1Dot6(SchemaDeprecationWarning):
55+
class SchemaDeprecationWarning1Dot6(BaseSchemaDeprecationWarning):
5656
"""Class for warnings about deprecated schema features in CycloneDX 1.6"""
5757
SCHEMA_VERSION: ClassVar[Literal[SchemaVersion.V1_6]] = SchemaVersion.V1_6
5858

5959

60-
class DeprecationWarning1Dot5(SchemaDeprecationWarning):
60+
class SchemaDeprecationWarning1Dot5(BaseSchemaDeprecationWarning):
6161
"""Class for warnings about deprecated schema features in CycloneDX 1.5"""
6262
SCHEMA_VERSION: ClassVar[Literal[SchemaVersion.V1_5]] = SchemaVersion.V1_5
6363

6464

65-
class DeprecationWarning1Dot4(SchemaDeprecationWarning):
65+
class SchemaDeprecationWarning1Dot4(BaseSchemaDeprecationWarning):
6666
"""Class for warnings about deprecated schema features in CycloneDX 1.4"""
6767
SCHEMA_VERSION: ClassVar[Literal[SchemaVersion.V1_4]] = SchemaVersion.V1_4
6868

6969

70-
class DeprecationWarning1Dot3(SchemaDeprecationWarning):
70+
class SchemaDeprecationWarning1Dot3(BaseSchemaDeprecationWarning):
7171
"""Class for warnings about deprecated schema features in CycloneDX 1.3"""
7272
SCHEMA_VERSION: ClassVar[Literal[SchemaVersion.V1_3]] = SchemaVersion.V1_3
7373

7474

75-
class DeprecationWarning1Dot2(SchemaDeprecationWarning):
75+
class SchemaDeprecationWarning1Dot2(BaseSchemaDeprecationWarning):
7676
"""Class for warnings about deprecated schema features in CycloneDX 1.2"""
7777
SCHEMA_VERSION: ClassVar[Literal[SchemaVersion.V1_2]] = SchemaVersion.V1_2
7878

7979

80-
class DeprecationWarning1Dot1(SchemaDeprecationWarning):
80+
class SchemaDeprecationWarning1Dot1(BaseSchemaDeprecationWarning):
8181
"""Class for warnings about deprecated schema features in CycloneDX 1.1"""
8282
SCHEMA_VERSION: ClassVar[Literal[SchemaVersion.V1_1]] = SchemaVersion.V1_1

examples/complex_deserialize.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from cyclonedx.exception import MissingOptionalDependencyException
2626
from cyclonedx.model.bom import Bom
2727
from cyclonedx.schema import OutputFormat, SchemaVersion
28-
from cyclonedx.schema.deprecation import SchemaDeprecationWarning
28+
from cyclonedx.schema.deprecation import BaseSchemaDeprecationWarning
2929
from cyclonedx.validation import make_schemabased_validator
3030
from cyclonedx.validation.json import JsonStrictValidator
3131

@@ -157,7 +157,7 @@
157157
except MissingOptionalDependencyException as error:
158158
print('JSON-validation was skipped due to', error)
159159
with warnings.catch_warnings():
160-
warnings.filterwarnings('ignore', category=SchemaDeprecationWarning)
160+
warnings.filterwarnings('ignore', category=BaseSchemaDeprecationWarning)
161161
bom_from_json = Bom.from_json( # type: ignore[attr-defined]
162162
json_loads(json_data))
163163
print('bom_from_json', repr(bom_from_json))
@@ -260,7 +260,7 @@
260260
except MissingOptionalDependencyException as error:
261261
print('XML-validation was skipped due to', error)
262262
with warnings.catch_warnings():
263-
warnings.filterwarnings('ignore', category=SchemaDeprecationWarning)
263+
warnings.filterwarnings('ignore', category=BaseSchemaDeprecationWarning)
264264
bom_from_xml = Bom.from_xml( # type: ignore[attr-defined]
265265
SafeElementTree.fromstring(xml_data))
266266
print('bom_from_xml', repr(bom_from_xml))

0 commit comments

Comments
 (0)