-
-
Notifications
You must be signed in to change notification settings - Fork 54
feat: decorate deprecated symbols #839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: decorate deprecated symbols #839
Conversation
Signed-off-by: Souta Kawahara <souta.kawahara@almalinux.org>
Signed-off-by: Souta Kawahara <souta.kawahara@almalinux.org>
dd002bf
to
61c5449
Compare
…ocations Signed-off-by: Souta Kawahara <souta.kawahara@almalinux.org>
61c5449
to
223ebf7
Compare
mypy tests seem to be failing.
The corresponding source code is as follows:
I've implemented this try-except block because the deprecated attribute became part of the standard warnings module in Python 3.13. For earlier Python versions, it falls back to typing_extensions. I think this approach should work correctly at runtime. |
[...]
the data models are deprecated from a specification's perspective, I might revert these changes... as out code clearly states:
|
cyclonedx/model/service.py
Outdated
@@ -259,6 +261,10 @@ def data(self) -> 'SortedSet[DataClassification]': | |||
|
|||
@data.setter | |||
def data(self, data: Iterable[DataClassification]) -> None: | |||
if data: | |||
warn('`@.data` is deprecated from CycloneDX v1.5 onwards. ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revertred. adding new warnings is not in the scope of the ticket, nor shall it be part of this very PR.
please create a new ticket/PR for this topic.
f8802e1
to
7708f47
Compare
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
7708f47
to
39de6d1
Compare
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
cyclonedx/model/tool.py
Outdated
@@ -37,6 +42,12 @@ | |||
from py_serializable import ObjectMetadataLibrary, ViewType | |||
|
|||
|
|||
@deprecated( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted, as the added statement is not true. the data model itself was never deprecated. it is just the usage in another model, that is deprecated in certain versions of CycloneDX.
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
thanks for all the effort. some feedback:
in general, this library/implementation intents to support many versions of CycloneDX on a semantics level. |
this was released via https://github.com/CycloneDX/cyclonedx-python-lib/releases/tag/v10.4.0 |
part of #760
First off, the BomRefHelper and LicenseRepositoryHelper classes, which you can find in cyclonedx/serialization/init.py, are already deprecated. We can fix this by applying the
@deprecated
annotation to them. On the other hand, the License ExpressionAcknowledgement symbol in cyclonedx/model/license.py is also deprecated, but since it's not a class, function, or method, we can't use the@deprecated
annotation there. I haven't made any changes to it in this patch.Currently, most of our DeprecationWarning outputs happen when a class attribute is deprecated. Take the BomMetaData class, for instance:
Because of this, we can't simply replace these direct warn() calls with
@deprecated
annotations.We also looked into other parts of the source code that are deprecated but aren't currently throwing DeprecationWarnings. I've found two candidates: dataClassification and the Tool class, both of which might have been deprecated in CycloneDX 1.5.
For the Tool class, it's pretty clear that tool-related data should now be stored in other classes, like Component. This means the Tool class itself should be deprecated, and since it's a class, we can use the
@deprecated
annotation on it.Conversely, the dataClassification class has a different story. Here, it's more about where the data is placed rather than the class itself being deprecated.
So, similar to existing implementations, I've added a warn() call to the Service class, which holds a dataClassification instance as an attribute, to emit the warning there.