From 2e283abed0b67e9e70c825e0d7c6ad7e6691c678 Mon Sep 17 00:00:00 2001 From: Rodney Richardson Date: Mon, 30 May 2022 11:05:21 +0100 Subject: [PATCH] Fix SortedSet type hints for python < 3.8 Signed-off-by: Rodney Richardson --- cyclonedx/model/__init__.py | 10 +++++----- cyclonedx/model/bom.py | 14 +++++++------- cyclonedx/model/component.py | 30 +++++++++++++++--------------- cyclonedx/model/dependency.py | 2 +- cyclonedx/model/issue.py | 2 +- cyclonedx/model/release_note.py | 10 +++++----- cyclonedx/model/service.py | 12 ++++++------ cyclonedx/model/vulnerability.py | 20 ++++++++++---------- 8 files changed, 50 insertions(+), 50 deletions(-) diff --git a/cyclonedx/model/__init__.py b/cyclonedx/model/__init__.py index 88e4868a..0c9693b0 100644 --- a/cyclonedx/model/__init__.py +++ b/cyclonedx/model/__init__.py @@ -505,7 +505,7 @@ def type(self, type_: ExternalReferenceType) -> None: self._type = type_ @property - def hashes(self) -> SortedSet[HashType]: + def hashes(self) -> "SortedSet[HashType]": """ The hashes of the external reference (if applicable). @@ -1036,7 +1036,7 @@ def name(self, name: Optional[str]) -> None: self._name = name @property - def url(self) -> SortedSet[XsUri]: + def url(self) -> "SortedSet[XsUri]": """ Get a list of URLs of the organization. Multiple URLs are allowed. @@ -1050,7 +1050,7 @@ def url(self, urls: Iterable[XsUri]) -> None: self._url = SortedSet(urls) @property - def contact(self) -> SortedSet[OrganizationalContact]: + def contact(self) -> "SortedSet[OrganizationalContact]": """ Get a list of contact person at the organization. Multiple contacts are allowed. @@ -1137,7 +1137,7 @@ def version(self, version: Optional[str]) -> None: self._version = version @property - def hashes(self) -> SortedSet[HashType]: + def hashes(self) -> "SortedSet[HashType]": """ The hashes of the tool (if applicable). @@ -1151,7 +1151,7 @@ def hashes(self, hashes: Iterable[HashType]) -> None: self._hashes = SortedSet(hashes) @property - def external_references(self) -> SortedSet[ExternalReference]: + def external_references(self) -> "SortedSet[ExternalReference]": """ External References provide a way to document systems, sites, and information that may be relevant but which are not included with the BOM. diff --git a/cyclonedx/model/bom.py b/cyclonedx/model/bom.py index 02f0d943..64e41b0b 100644 --- a/cyclonedx/model/bom.py +++ b/cyclonedx/model/bom.py @@ -71,7 +71,7 @@ def timestamp(self, timestamp: datetime) -> None: self._timestamp = timestamp @property - def tools(self) -> SortedSet[Tool]: + def tools(self) -> "SortedSet[Tool]": """ Tools used to create this BOM. @@ -85,7 +85,7 @@ def tools(self, tools: Iterable[Tool]) -> None: self._tools = SortedSet(tools) @property - def authors(self) -> SortedSet[OrganizationalContact]: + def authors(self) -> "SortedSet[OrganizationalContact]": """ The person(s) who created the BOM. @@ -157,7 +157,7 @@ def supplier(self, supplier: Optional[OrganizationalEntity]) -> None: self._supplier = supplier @property - def licenses(self) -> SortedSet[LicenseChoice]: + def licenses(self) -> "SortedSet[LicenseChoice]": """ A optional list of statements about how this BOM is licensed. @@ -171,7 +171,7 @@ def licenses(self, licenses: Iterable[LicenseChoice]) -> None: self._licenses = SortedSet(licenses) @property - def properties(self) -> SortedSet[Property]: + def properties(self) -> "SortedSet[Property]": """ Provides the ability to document properties in a key/value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. @@ -275,7 +275,7 @@ def metadata(self, metadata: BomMetaData) -> None: self._metadata = metadata @property - def components(self) -> SortedSet[Component]: + def components(self) -> "SortedSet[Component]": """ Get all the Components currently in this Bom. @@ -329,7 +329,7 @@ def has_component(self, component: Component) -> bool: return component in self.components @property - def services(self) -> SortedSet[Service]: + def services(self) -> "SortedSet[Service]": """ Get all the Services currently in this Bom. @@ -343,7 +343,7 @@ def services(self, services: Iterable[Service]) -> None: self._services = SortedSet(services) @property - def external_references(self) -> SortedSet[ExternalReference]: + def external_references(self) -> "SortedSet[ExternalReference]": """ Provides the ability to document external references related to the BOM or to the project the BOM describes. diff --git a/cyclonedx/model/component.py b/cyclonedx/model/component.py index 35733392..b91a719e 100644 --- a/cyclonedx/model/component.py +++ b/cyclonedx/model/component.py @@ -179,7 +179,7 @@ def __init__(self, *, licenses: Optional[Iterable[LicenseChoice]] = None, self.copyright = SortedSet(copyright_ or []) @property - def licenses(self) -> SortedSet[LicenseChoice]: + def licenses(self) -> "SortedSet[LicenseChoice]": """ Optional list of licenses obtained during analysis. @@ -193,7 +193,7 @@ def licenses(self, licenses: Iterable[LicenseChoice]) -> None: self._licenses = SortedSet(licenses) @property - def copyright(self) -> SortedSet[Copyright]: + def copyright(self) -> "SortedSet[Copyright]": """ Optional list of copyright statements. @@ -369,7 +369,7 @@ def diff(self, diff: Optional[Diff]) -> None: self._diff = diff @property - def resolves(self) -> SortedSet[IssueType]: + def resolves(self) -> "SortedSet[IssueType]": """ Optional list of issues resolved by this patch. @@ -431,7 +431,7 @@ def __init__(self, *, ancestors: Optional[Iterable['Component']] = None, self.notes = notes @property - def ancestors(self) -> SortedSet['Component']: + def ancestors(self) -> "SortedSet['Component']": """ Describes zero or more components in which a component is derived from. This is commonly used to describe forks from existing projects where the forked version contains a ancestor node containing the original component it @@ -451,7 +451,7 @@ def ancestors(self, ancestors: Iterable['Component']) -> None: self._ancestors = SortedSet(ancestors) @property - def descendants(self) -> SortedSet['Component']: + def descendants(self) -> "SortedSet['Component']": """ Descendants are the exact opposite of ancestors. This provides a way to document all forks (and their forks) of an original or root component. @@ -466,7 +466,7 @@ def descendants(self, descendants: Iterable['Component']) -> None: self._descendants = SortedSet(descendants) @property - def variants(self) -> SortedSet['Component']: + def variants(self) -> "SortedSet['Component']": """ Variants describe relations where the relationship between the components are not known. For example, if Component A contains nearly identical code to Component B. They are both related, but it is unclear if one is @@ -482,7 +482,7 @@ def variants(self, variants: Iterable['Component']) -> None: self._variants = SortedSet(variants) @property - def commits(self) -> SortedSet[Commit]: + def commits(self) -> "SortedSet[Commit]": """ A list of zero or more commits which provide a trail describing how the component deviates from an ancestor, descendant, or variant. @@ -497,7 +497,7 @@ def commits(self, commits: Iterable[Commit]) -> None: self._commits = SortedSet(commits) @property - def patches(self) -> SortedSet[Patch]: + def patches(self) -> "SortedSet[Patch]": """ A list of zero or more patches describing how the component deviates from an ancestor, descendant, or variant. Patches may be complimentary to commits or may be used in place of commits. @@ -937,7 +937,7 @@ def scope(self, scope: Optional[ComponentScope]) -> None: self._scope = scope @property - def hashes(self) -> SortedSet[HashType]: + def hashes(self) -> "SortedSet[HashType]": """ Optional list of hashes that help specify the integrity of this Component. @@ -951,7 +951,7 @@ def hashes(self, hashes: Iterable[HashType]) -> None: self._hashes = SortedSet(hashes) @property - def licenses(self) -> SortedSet[LicenseChoice]: + def licenses(self) -> "SortedSet[LicenseChoice]": """ A optional list of statements about how this Component is licensed. @@ -1041,7 +1041,7 @@ def pedigree(self, pedigree: Optional[Pedigree]) -> None: self._pedigree = pedigree @property - def external_references(self) -> SortedSet[ExternalReference]: + def external_references(self) -> "SortedSet[ExternalReference]": """ Provides the ability to document external references related to the component or to the project the component describes. @@ -1056,7 +1056,7 @@ def external_references(self, external_references: Iterable[ExternalReference]) self._external_references = SortedSet(external_references) @property - def properties(self) -> SortedSet[Property]: + def properties(self) -> "SortedSet[Property]": """ Provides the ability to document properties in a key/value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. @@ -1071,7 +1071,7 @@ def properties(self, properties: Iterable[Property]) -> None: self._properties = SortedSet(properties) @property - def components(self) -> SortedSet['Component']: + def components(self) -> "SortedSet['Component']": """ A list of software and hardware components included in the parent component. This is not a dependency tree. It provides a way to specify a hierarchical representation of component assemblies, similar to system -> subsystem @@ -1115,7 +1115,7 @@ def release_notes(self, release_notes: Optional[ReleaseNotes]) -> None: self._release_notes = release_notes @property - def dependencies(self) -> SortedSet[BomRef]: + def dependencies(self) -> "SortedSet[BomRef]": """ Set of `BomRef` that this Component depends on. @@ -1141,7 +1141,7 @@ def add_vulnerability(self, vulnerability: Vulnerability) -> None: """ self.__vulnerabilites.add(vulnerability) - def get_vulnerabilities(self) -> SortedSet[Vulnerability]: + def get_vulnerabilities(self) -> "SortedSet[Vulnerability]": """ Get all the Vulnerabilities for this Component. diff --git a/cyclonedx/model/dependency.py b/cyclonedx/model/dependency.py index 6b44ac66..ee5b9e77 100644 --- a/cyclonedx/model/dependency.py +++ b/cyclonedx/model/dependency.py @@ -41,7 +41,7 @@ def ref(self) -> BomRef: return self._ref @property - def depends_on(self) -> SortedSet[BomRef]: + def depends_on(self) -> "SortedSet[BomRef]": return self._depends_on @depends_on.setter diff --git a/cyclonedx/model/issue.py b/cyclonedx/model/issue.py index 12703e8f..e401da43 100644 --- a/cyclonedx/model/issue.py +++ b/cyclonedx/model/issue.py @@ -188,7 +188,7 @@ def source(self, source: Optional[IssueTypeSource]) -> None: self._source = source @property - def references(self) -> SortedSet[XsUri]: + def references(self) -> "SortedSet[XsUri]": """ Any reference URLs related to this issue. diff --git a/cyclonedx/model/release_note.py b/cyclonedx/model/release_note.py index df88a3ff..87e0bc10 100644 --- a/cyclonedx/model/release_note.py +++ b/cyclonedx/model/release_note.py @@ -132,7 +132,7 @@ def timestamp(self, timestamp: Optional[datetime]) -> None: self._timestamp = timestamp @property - def aliases(self) -> SortedSet[str]: + def aliases(self) -> "SortedSet[str]": """ One or more alternate names the release may be referred to. This may include unofficial terms used by development and marketing teams (e.g. code names). @@ -147,7 +147,7 @@ def aliases(self, aliases: Iterable[str]) -> None: self._aliases = SortedSet(aliases) @property - def tags(self) -> SortedSet[str]: + def tags(self) -> "SortedSet[str]": """ One or more tags that may aid in search or retrieval of the release note. @@ -161,7 +161,7 @@ def tags(self, tags: Iterable[str]) -> None: self._tags = SortedSet(tags) @property - def resolves(self) -> SortedSet[IssueType]: + def resolves(self) -> "SortedSet[IssueType]": """ A collection of issues that have been resolved. @@ -175,7 +175,7 @@ def resolves(self, resolves: Iterable[IssueType]) -> None: self._resolves = SortedSet(resolves) @property - def notes(self) -> SortedSet[Note]: + def notes(self) -> "SortedSet[Note]": """ Zero or more release notes containing the locale and content. Multiple note elements may be specified to support release notes in a wide variety of languages. @@ -190,7 +190,7 @@ def notes(self, notes: Iterable[Note]) -> None: self._notes = SortedSet(notes) @property - def properties(self) -> SortedSet[Property]: + def properties(self) -> "SortedSet[Property]": """ Provides the ability to document properties in a name-value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. Unlike diff --git a/cyclonedx/model/service.py b/cyclonedx/model/service.py index 6efc97c3..a02c7ebb 100644 --- a/cyclonedx/model/service.py +++ b/cyclonedx/model/service.py @@ -158,7 +158,7 @@ def description(self, description: Optional[str]) -> None: self._description = description @property - def endpoints(self) -> SortedSet[XsUri]: + def endpoints(self) -> "SortedSet[XsUri]": """ A list of endpoints URI's this service provides. @@ -206,7 +206,7 @@ def x_trust_boundary(self, x_trust_boundary: Optional[bool]) -> None: self._x_trust_boundary = x_trust_boundary @property - def data(self) -> SortedSet[DataClassification]: + def data(self) -> "SortedSet[DataClassification]": """ Specifies the data classification. @@ -220,7 +220,7 @@ def data(self, data: Iterable[DataClassification]) -> None: self._data = SortedSet(data) @property - def licenses(self) -> SortedSet[LicenseChoice]: + def licenses(self) -> "SortedSet[LicenseChoice]": """ A optional list of statements about how this Service is licensed. @@ -234,7 +234,7 @@ def licenses(self, licenses: Iterable[LicenseChoice]) -> None: self._licenses = SortedSet(licenses) @property - def external_references(self) -> SortedSet[ExternalReference]: + def external_references(self) -> "SortedSet[ExternalReference]": """ Provides the ability to document external references related to the Service. @@ -248,7 +248,7 @@ def external_references(self, external_references: Iterable[ExternalReference]) self._external_references = SortedSet(external_references) @property - def services(self) -> SortedSet['Service']: + def services(self) -> "SortedSet['Service']": """ A list of services included or deployed behind the parent service. @@ -280,7 +280,7 @@ def release_notes(self, release_notes: Optional[ReleaseNotes]) -> None: self._release_notes = release_notes @property - def properties(self) -> SortedSet[Property]: + def properties(self) -> "SortedSet[Property]": """ Provides the ability to document properties in a key/value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. diff --git a/cyclonedx/model/vulnerability.py b/cyclonedx/model/vulnerability.py index 31e05dcb..a189bd20 100644 --- a/cyclonedx/model/vulnerability.py +++ b/cyclonedx/model/vulnerability.py @@ -158,7 +158,7 @@ def ref(self, ref: str) -> None: self._ref = ref @property - def versions(self) -> SortedSet[BomTargetVersionRange]: + def versions(self) -> "SortedSet[BomTargetVersionRange]": """ Zero or more individual versions or range of versions. @@ -239,7 +239,7 @@ def justification(self, justification: Optional[ImpactAnalysisJustification]) -> self._justification = justification @property - def response(self) -> SortedSet[ImpactAnalysisResponse]: + def response(self) -> "SortedSet[ImpactAnalysisResponse]": """ A list of responses to the vulnerability by the manufacturer, supplier, or project responsible for the affected component or service. More than one response is allowed. Responses are strongly encouraged for @@ -723,7 +723,7 @@ def __init__(self, *, organizations: Optional[Iterable[OrganizationalEntity]] = self.individuals = SortedSet(individuals or []) @property - def organizations(self) -> SortedSet[OrganizationalEntity]: + def organizations(self) -> "SortedSet[OrganizationalEntity]": """ The organizations credited with vulnerability discovery. @@ -737,7 +737,7 @@ def organizations(self, organizations: Iterable[OrganizationalEntity]) -> None: self._organizations = SortedSet(organizations) @property - def individuals(self) -> SortedSet[OrganizationalContact]: + def individuals(self) -> "SortedSet[OrganizationalContact]": """ The individuals, not associated with organizations, that are credited with vulnerability discovery. @@ -855,7 +855,7 @@ def source(self, source: Optional[VulnerabilitySource]) -> None: self._source = source @property - def references(self) -> SortedSet[VulnerabilityReference]: + def references(self) -> "SortedSet[VulnerabilityReference]": """ Zero or more pointers to vulnerabilities that are the equivalent of the vulnerability specified. Often times, the same vulnerability may exist in multiple sources of vulnerability intelligence, but have different @@ -872,7 +872,7 @@ def references(self, references: Iterable[VulnerabilityReference]) -> None: self._references = SortedSet(references) @property - def ratings(self) -> SortedSet[VulnerabilityRating]: + def ratings(self) -> "SortedSet[VulnerabilityRating]": """ List of vulnerability ratings. @@ -886,7 +886,7 @@ def ratings(self, ratings: Iterable[VulnerabilityRating]) -> None: self._ratings = SortedSet(ratings) @property - def cwes(self) -> SortedSet[int]: + def cwes(self) -> "SortedSet[int]": """ A list of CWE (Common Weakness Enumeration) identifiers. @@ -946,7 +946,7 @@ def recommendation(self, recommendation: Optional[str]) -> None: self._recommendation = recommendation @property - def advisories(self) -> SortedSet[VulnerabilityAdvisory]: + def advisories(self) -> "SortedSet[VulnerabilityAdvisory]": """ Advisories relating to the Vulnerability. @@ -1016,7 +1016,7 @@ def credits(self, credits: Optional[VulnerabilityCredits]) -> None: self._credits = credits @property - def tools(self) -> SortedSet[Tool]: + def tools(self) -> "SortedSet[Tool]": """ The tool(s) used to identify, confirm, or score the vulnerability. @@ -1044,7 +1044,7 @@ def analysis(self, analysis: Optional[VulnerabilityAnalysis]) -> None: self._analysis = analysis @property - def affects(self) -> SortedSet[BomTarget]: + def affects(self) -> "SortedSet[BomTarget]": """ The components or services that are affected by the vulnerability.