Skip to content

Commit 691b68f

Browse files
committed
docs
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent 36567f1 commit 691b68f

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

cyclonedx/schema/deprecation.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,60 @@
1515
# SPDX-License-Identifier: Apache-2.0
1616
# Copyright (c) OWASP Foundation. All Rights Reserved.
1717

18+
19+
"""
20+
CycloneDX Schema Deprecation Warnings
21+
=====================================
22+
23+
This module provides warning classes for deprecated features in CycloneDX schemas.
24+
Each warning class corresponds to a specific schema version, enabling downstream
25+
code to catch, filter, or otherwise handle schema-specific deprecation warnings.
26+
27+
Intended Usage
28+
--------------
29+
30+
Downstream consumers can manage warnings using Python's ``warnings`` module.
31+
Common scenarios include:
32+
33+
- Filtering by schema version
34+
- Suppressing warnings in tests or batch processing
35+
- Logging or reporting deprecation warnings without raising exceptions
36+
37+
Example
38+
-------
39+
40+
.. code-block:: python
41+
42+
import warnings
43+
from cyclonedx.schema.deprecation import (
44+
BaseSchemaDeprecationWarning,
45+
SchemaDeprecationWarning1Dot7,
46+
)
47+
48+
# Suppress all CycloneDX schema deprecation warnings
49+
warnings.filterwarnings("ignore", category=BaseSchemaDeprecationWarning)
50+
51+
# Suppress only warnings specific to schema version 1.7
52+
warnings.filterwarnings("ignore", category=SchemaDeprecationWarning1Dot7)
53+
54+
Notes
55+
-----
56+
57+
- All deprecation warnings inherit from :class:`BaseSchemaDeprecationWarning`.
58+
- The ``SCHEMA_VERSION`` class variable indicates the CycloneDX schema version
59+
where the feature became deprecated.
60+
- These warning classes are designed for downstream **filtering and logging**,
61+
not for raising exceptions.
62+
"""
63+
64+
1865
from abc import ABC
1966
from typing import ClassVar, Literal, Optional
2067
from warnings import warn
2168

2269
from . import SchemaVersion
2370

71+
2472
__all__ = [
2573
'BaseSchemaDeprecationWarning',
2674
'SchemaDeprecationWarning1Dot1',

0 commit comments

Comments
 (0)