Skip to content

Commit 5b74b0f

Browse files
authored
style: model args - one per line (#643)
this should make future PR reviews easier, since adding new args in the middle will not cause complete code blocks to change, but is just a new line ... Signed-off-by: Jan Kowalleck <[email protected]>
1 parent ba6dee4 commit 5b74b0f

File tree

10 files changed

+374
-163
lines changed

10 files changed

+374
-163
lines changed

cyclonedx/model/__init__.py

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ class DataClassification:
7979
https://cyclonedx.org/docs/1.4/xml/#type_dataClassificationType
8080
"""
8181

82-
def __init__(self, *, flow: DataFlow, classification: str) -> None:
82+
def __init__(
83+
self, *,
84+
flow: DataFlow,
85+
classification: str,
86+
) -> None:
8387
self.flow = flow
8488
self.classification = classification
8589

@@ -165,8 +169,12 @@ class AttachedText:
165169

166170
DEFAULT_CONTENT_TYPE = 'text/plain'
167171

168-
def __init__(self, *, content: str, content_type: str = DEFAULT_CONTENT_TYPE,
169-
encoding: Optional[Encoding] = None) -> None:
172+
def __init__(
173+
self, *,
174+
content: str,
175+
content_type: str = DEFAULT_CONTENT_TYPE,
176+
encoding: Optional[Encoding] = None,
177+
) -> None:
170178
self.content_type = content_type
171179
self.encoding = encoding
172180
self.content = content
@@ -435,7 +443,11 @@ def from_composite_str(composite_hash: str) -> 'HashType':
435443

436444
raise UnknownHashTypeException(f'Unable to determine hash type from {composite_hash!r}')
437445

438-
def __init__(self, *, alg: HashAlgorithm, content: str) -> None:
446+
def __init__(
447+
self, *,
448+
alg: HashAlgorithm,
449+
content: str,
450+
) -> None:
439451
self.alg = alg
440452
self.content = content
441453

@@ -735,8 +747,13 @@ class ExternalReference:
735747
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.3/#type_externalReference
736748
"""
737749

738-
def __init__(self, *, type: ExternalReferenceType, url: XsUri, comment: Optional[str] = None,
739-
hashes: Optional[Iterable[HashType]] = None) -> None:
750+
def __init__(
751+
self, *,
752+
type: ExternalReferenceType,
753+
url: XsUri,
754+
comment: Optional[str] = None,
755+
hashes: Optional[Iterable[HashType]] = None,
756+
) -> None:
740757
self.url = url
741758
self.comment = comment
742759
self.type = type
@@ -845,7 +862,11 @@ class Property:
845862
Specifies an individual property with a name and value.
846863
"""
847864

848-
def __init__(self, *, name: str, value: Optional[str] = None) -> None:
865+
def __init__(
866+
self, *,
867+
name: str,
868+
value: Optional[str] = None,
869+
) -> None:
849870
self.name = name
850871
self.value = value
851872

@@ -914,8 +935,12 @@ class NoteText:
914935

915936
DEFAULT_CONTENT_TYPE: str = 'text/plain'
916937

917-
def __init__(self, *, content: str, content_type: Optional[str] = None,
918-
encoding: Optional[Encoding] = None) -> None:
938+
def __init__(
939+
self, *,
940+
content: str,
941+
content_type: Optional[str] = None,
942+
encoding: Optional[Encoding] = None,
943+
) -> None:
919944
self.content = content
920945
self.content_type = content_type or NoteText.DEFAULT_CONTENT_TYPE
921946
self.encoding = encoding
@@ -1003,7 +1028,11 @@ class Note:
10031028

10041029
_LOCALE_TYPE_REGEX = re.compile(r'^[a-z]{2}(?:\-[A-Z]{2})?$')
10051030

1006-
def __init__(self, *, text: NoteText, locale: Optional[str] = None) -> None:
1031+
def __init__(
1032+
self, *,
1033+
text: NoteText,
1034+
locale: Optional[str] = None,
1035+
) -> None:
10071036
self.text = text
10081037
self.locale = locale
10091038

@@ -1083,9 +1112,14 @@ class Tool:
10831112
See the CycloneDX Schema for toolType: https://cyclonedx.org/docs/1.3/#type_toolType
10841113
"""
10851114

1086-
def __init__(self, *, vendor: Optional[str] = None, name: Optional[str] = None, version: Optional[str] = None,
1087-
hashes: Optional[Iterable[HashType]] = None,
1088-
external_references: Optional[Iterable[ExternalReference]] = None) -> None:
1115+
def __init__(
1116+
self, *,
1117+
vendor: Optional[str] = None,
1118+
name: Optional[str] = None,
1119+
version: Optional[str] = None,
1120+
hashes: Optional[Iterable[HashType]] = None,
1121+
external_references: Optional[Iterable[ExternalReference]] = None,
1122+
) -> None:
10891123
self.vendor = vendor
10901124
self.name = name
10911125
self.version = version
@@ -1203,8 +1237,12 @@ class IdentifiableAction:
12031237
See the CycloneDX specification: https://cyclonedx.org/docs/1.4/xml/#type_identifiableActionType
12041238
"""
12051239

1206-
def __init__(self, *, timestamp: Optional[datetime] = None, name: Optional[str] = None,
1207-
email: Optional[str] = None) -> None:
1240+
def __init__(
1241+
self, *,
1242+
timestamp: Optional[datetime] = None,
1243+
name: Optional[str] = None,
1244+
email: Optional[str] = None,
1245+
) -> None:
12081246
if not timestamp and not name and not email:
12091247
raise NoPropertiesProvidedException(
12101248
'At least one of `timestamp`, `name` or `email` must be provided for an `IdentifiableAction`.'
@@ -1287,7 +1325,10 @@ class Copyright:
12871325
See the CycloneDX specification: https://cyclonedx.org/docs/1.4/xml/#type_copyrightsType
12881326
"""
12891327

1290-
def __init__(self, *, text: str) -> None:
1328+
def __init__(
1329+
self, *,
1330+
text: str,
1331+
) -> None:
12911332
self.text = text
12921333

12931334
@property

cyclonedx/model/bom.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ class BomMetaData:
5959
See the CycloneDX Schema for Bom metadata: https://cyclonedx.org/docs/1.5/#type_metadata
6060
"""
6161

62-
def __init__(self, *, tools: Optional[Iterable[Tool]] = None,
63-
authors: Optional[Iterable[OrganizationalContact]] = None, component: Optional[Component] = None,
64-
supplier: Optional[OrganizationalEntity] = None,
65-
licenses: Optional[Iterable[License]] = None,
66-
properties: Optional[Iterable[Property]] = None,
67-
timestamp: Optional[datetime] = None,
68-
manufacturer: Optional[OrganizationalEntity] = None,
69-
# Deprecated as of v1.6
70-
manufacture: Optional[OrganizationalEntity] = None) -> None:
62+
def __init__(
63+
self, *,
64+
tools: Optional[Iterable[Tool]] = None,
65+
authors: Optional[Iterable[OrganizationalContact]] = None,
66+
component: Optional[Component] = None,
67+
supplier: Optional[OrganizationalEntity] = None,
68+
licenses: Optional[Iterable[License]] = None,
69+
properties: Optional[Iterable[Property]] = None,
70+
timestamp: Optional[datetime] = None,
71+
manufacturer: Optional[OrganizationalEntity] = None,
72+
# Deprecated as of v1.6
73+
manufacture: Optional[OrganizationalEntity] = None,
74+
) -> None:
7175
self.timestamp = timestamp or _get_now_utc()
7276
self.tools = tools or [] # type:ignore[assignment]
7377
self.authors = authors or [] # type:ignore[assignment]
@@ -304,14 +308,18 @@ class Bom:
304308
`cyclonedx.output.BaseOutput` to produce a CycloneDX document according to a specific schema version and format.
305309
"""
306310

307-
def __init__(self, *, components: Optional[Iterable[Component]] = None,
308-
services: Optional[Iterable[Service]] = None,
309-
external_references: Optional[Iterable[ExternalReference]] = None,
310-
serial_number: Optional[UUID] = None, version: int = 1,
311-
metadata: Optional[BomMetaData] = None,
312-
dependencies: Optional[Iterable[Dependency]] = None,
313-
vulnerabilities: Optional[Iterable[Vulnerability]] = None,
314-
properties: Optional[Iterable[Property]] = None) -> None:
311+
def __init__(
312+
self, *,
313+
components: Optional[Iterable[Component]] = None,
314+
services: Optional[Iterable[Service]] = None,
315+
external_references: Optional[Iterable[ExternalReference]] = None,
316+
serial_number: Optional[UUID] = None,
317+
version: int = 1,
318+
metadata: Optional[BomMetaData] = None,
319+
dependencies: Optional[Iterable[Dependency]] = None,
320+
vulnerabilities: Optional[Iterable[Vulnerability]] = None,
321+
properties: Optional[Iterable[Property]] = None,
322+
) -> None:
315323
"""
316324
Create a new Bom that you can manually/programmatically add data to later.
317325

cyclonedx/model/component.py

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@ class Commit:
7373
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_commitType
7474
"""
7575

76-
def __init__(self, *, uid: Optional[str] = None, url: Optional[XsUri] = None,
77-
author: Optional[IdentifiableAction] = None, committer: Optional[IdentifiableAction] = None,
78-
message: Optional[str] = None) -> None:
76+
def __init__(
77+
self, *,
78+
uid: Optional[str] = None,
79+
url: Optional[XsUri] = None,
80+
author: Optional[IdentifiableAction] = None,
81+
committer: Optional[IdentifiableAction] = None,
82+
message: Optional[str] = None,
83+
) -> None:
7984
if not uid and not url and not author and not committer and not message:
8085
raise NoPropertiesProvidedException(
8186
'At least one of `uid`, `url`, `author`, `committer` or `message` must be provided for a `Commit`.'
@@ -195,8 +200,11 @@ class ComponentEvidence:
195200
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_componentEvidenceType
196201
"""
197202

198-
def __init__(self, *, licenses: Optional[Iterable[License]] = None,
199-
copyright: Optional[Iterable[Copyright]] = None) -> None:
203+
def __init__(
204+
self, *,
205+
licenses: Optional[Iterable[License]] = None,
206+
copyright: Optional[Iterable[Copyright]] = None,
207+
) -> None:
200208
if not licenses and not copyright:
201209
raise NoPropertiesProvidedException(
202210
'At least one of `licenses` or `copyright` must be supplied for a `ComponentEvidence`.'
@@ -426,7 +434,11 @@ class Diff:
426434
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_diffType
427435
"""
428436

429-
def __init__(self, *, text: Optional[AttachedText] = None, url: Optional[XsUri] = None) -> None:
437+
def __init__(
438+
self, *,
439+
text: Optional[AttachedText] = None,
440+
url: Optional[XsUri] = None,
441+
) -> None:
430442
if not text and not url:
431443
raise NoPropertiesProvidedException(
432444
'At least one of `text` or `url` must be provided for a `Diff`.'
@@ -507,8 +519,12 @@ class Patch:
507519
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_patchType
508520
"""
509521

510-
def __init__(self, *, type: PatchClassification, diff: Optional[Diff] = None,
511-
resolves: Optional[Iterable[IssueType]] = None) -> None:
522+
def __init__(
523+
self, *,
524+
type: PatchClassification,
525+
diff: Optional[Diff] = None,
526+
resolves: Optional[Iterable[IssueType]] = None,
527+
) -> None:
512528
self.type = type
513529
self.diff = diff
514530
self.resolves = resolves or [] # type:ignore[assignment]
@@ -596,10 +612,15 @@ class Pedigree:
596612
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_pedigreeType
597613
"""
598614

599-
def __init__(self, *, ancestors: Optional[Iterable['Component']] = None,
600-
descendants: Optional[Iterable['Component']] = None, variants: Optional[Iterable['Component']] = None,
601-
commits: Optional[Iterable[Commit]] = None, patches: Optional[Iterable[Patch]] = None,
602-
notes: Optional[str] = None) -> None:
615+
def __init__(
616+
self, *,
617+
ancestors: Optional[Iterable['Component']] = None,
618+
descendants: Optional[Iterable['Component']] = None,
619+
variants: Optional[Iterable['Component']] = None,
620+
commits: Optional[Iterable[Commit]] = None,
621+
patches: Optional[Iterable[Patch]] = None,
622+
notes: Optional[str] = None,
623+
) -> None:
603624
if not ancestors and not descendants and not variants and not commits and not patches and not notes:
604625
raise NoPropertiesProvidedException(
605626
'At least one of `ancestors`, `descendants`, `variants`, `commits`, `patches` or `notes` must be '
@@ -748,9 +769,16 @@ class Swid:
748769
See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_swidType
749770
"""
750771

751-
def __init__(self, *, tag_id: str, name: str, version: Optional[str] = None,
752-
tag_version: Optional[int] = None, patch: Optional[bool] = None,
753-
text: Optional[AttachedText] = None, url: Optional[XsUri] = None) -> None:
772+
def __init__(
773+
self, *,
774+
tag_id: str,
775+
name: str,
776+
version: Optional[str] = None,
777+
tag_version: Optional[int] = None,
778+
patch: Optional[bool] = None,
779+
text: Optional[AttachedText] = None,
780+
url: Optional[XsUri] = None,
781+
) -> None:
754782
self.tag_id = tag_id
755783
self.name = name
756784
self.version = version
@@ -1031,25 +1059,40 @@ def for_file(absolute_file_path: str, path_for_bom: Optional[str]) -> 'Component
10311059
)
10321060
)
10331061

1034-
def __init__(self, *,
1035-
name: str, type: ComponentType = ComponentType.LIBRARY,
1036-
mime_type: Optional[str] = None, bom_ref: Optional[Union[str, BomRef]] = None,
1037-
supplier: Optional[OrganizationalEntity] = None,
1038-
publisher: Optional[str] = None, group: Optional[str] = None, version: Optional[str] = None,
1039-
description: Optional[str] = None, scope: Optional[ComponentScope] = None,
1040-
hashes: Optional[Iterable[HashType]] = None, licenses: Optional[Iterable[License]] = None,
1041-
copyright: Optional[str] = None, purl: Optional[PackageURL] = None,
1042-
external_references: Optional[Iterable[ExternalReference]] = None,
1043-
properties: Optional[Iterable[Property]] = None, release_notes: Optional[ReleaseNotes] = None,
1044-
cpe: Optional[str] = None, swid: Optional[Swid] = None, pedigree: Optional[Pedigree] = None,
1045-
components: Optional[Iterable['Component']] = None, evidence: Optional[ComponentEvidence] = None,
1046-
modified: bool = False, manufacturer: Optional[OrganizationalEntity] = None,
1047-
authors: Optional[Iterable[OrganizationalContact]] = None,
1048-
omnibor_ids: Optional[Iterable[OmniborId]] = None, swhids: Optional[Iterable[Swhid]] = None,
1049-
crypto_properties: Optional[CryptoProperties] = None, tags: Optional[Iterable[str]] = None,
1050-
# Deprecated in v1.6
1051-
author: Optional[str] = None,
1052-
) -> None:
1062+
def __init__(
1063+
self, *,
1064+
name: str,
1065+
type: ComponentType = ComponentType.LIBRARY,
1066+
mime_type: Optional[str] = None,
1067+
bom_ref: Optional[Union[str, BomRef]] = None,
1068+
supplier: Optional[OrganizationalEntity] = None,
1069+
publisher: Optional[str] = None,
1070+
group: Optional[str] = None,
1071+
version: Optional[str] = None,
1072+
description: Optional[str] = None,
1073+
scope: Optional[ComponentScope] = None,
1074+
hashes: Optional[Iterable[HashType]] = None,
1075+
licenses: Optional[Iterable[License]] = None,
1076+
copyright: Optional[str] = None,
1077+
purl: Optional[PackageURL] = None,
1078+
external_references: Optional[Iterable[ExternalReference]] = None,
1079+
properties: Optional[Iterable[Property]] = None,
1080+
release_notes: Optional[ReleaseNotes] = None,
1081+
cpe: Optional[str] = None,
1082+
swid: Optional[Swid] = None,
1083+
pedigree: Optional[Pedigree] = None,
1084+
components: Optional[Iterable['Component']] = None,
1085+
evidence: Optional[ComponentEvidence] = None,
1086+
modified: bool = False,
1087+
manufacturer: Optional[OrganizationalEntity] = None,
1088+
authors: Optional[Iterable[OrganizationalContact]] = None,
1089+
omnibor_ids: Optional[Iterable[OmniborId]] = None,
1090+
swhids: Optional[Iterable[Swhid]] = None,
1091+
crypto_properties: Optional[CryptoProperties] = None,
1092+
tags: Optional[Iterable[str]] = None,
1093+
# Deprecated in v1.6
1094+
author: Optional[str] = None,
1095+
) -> None:
10531096
self.type = type
10541097
self.mime_type = mime_type
10551098
if isinstance(bom_ref, BomRef):

0 commit comments

Comments
 (0)