|
15 | 15 | # SPDX-License-Identifier: Apache-2.0 |
16 | 16 | # Copyright (c) OWASP Foundation. All Rights Reserved. |
17 | 17 |
|
| 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 | + |
18 | 65 | from abc import ABC |
19 | 66 | from typing import ClassVar, Literal, Optional |
20 | 67 | from warnings import warn |
21 | 68 |
|
22 | 69 | from . import SchemaVersion |
23 | 70 |
|
| 71 | + |
24 | 72 | __all__ = [ |
25 | 73 | 'BaseSchemaDeprecationWarning', |
26 | 74 | 'SchemaDeprecationWarning1Dot1', |
|
0 commit comments