Skip to content

Commit 1e841ab

Browse files
committed
type hint: Make Optional explicit (PEP 484)
PEP 484 prohibits implicit Optional. Note that this mass conversion is done automatically by https://github.com/hauntsaninja/no_implicit_optional as suggested by mypy, with a human review. Uses `... | None` style instead of `Optional[...]` since we are now using Python 3.10. Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
1 parent 4c9e2a6 commit 1e841ab

File tree

64 files changed

+193
-193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+193
-193
lines changed

src/spdx_tools/spdx/jsonschema/annotation_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class AnnotationConverter(TypedConverter[Annotation]):
1414
def _get_property_value(
15-
self, annotation: Annotation, annotation_property: AnnotationProperty, document: Document = None
15+
self, annotation: Annotation, annotation_property: AnnotationProperty, document: Document | None = None
1616
) -> Any:
1717
if annotation_property == AnnotationProperty.ANNOTATION_DATE:
1818
return datetime_to_iso_string(annotation.annotation_date)

src/spdx_tools/spdx/jsonschema/checksum_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_json_type(self) -> Type[JsonProperty]:
1717
return ChecksumProperty
1818

1919
def _get_property_value(
20-
self, checksum: Checksum, checksum_property: ChecksumProperty, _document: Document = None
20+
self, checksum: Checksum, checksum_property: ChecksumProperty, _document: Document | None = None
2121
) -> str:
2222
if checksum_property == ChecksumProperty.ALGORITHM:
2323
return algorithm_to_json_string(checksum.algorithm)

src/spdx_tools/spdx/jsonschema/converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TypedConverter(ABC, Generic[T]):
3333
"""
3434

3535
@abstractmethod
36-
def _get_property_value(self, instance: T, json_property: JsonProperty, document: Document = None) -> Any:
36+
def _get_property_value(self, instance: T, json_property: JsonProperty, document: Document | None = None) -> Any:
3737
raise NotImplementedError(MISSING_IMPLEMENTATION_MESSAGE)
3838

3939
@abstractmethod
@@ -50,7 +50,7 @@ def json_property_name(self, json_property: JsonProperty) -> str:
5050
def requires_full_document(self) -> bool:
5151
return False
5252

53-
def convert(self, instance: T, document: Document = None) -> Dict:
53+
def convert(self, instance: T, document: Document | None = None) -> Dict:
5454
if not isinstance(instance, self.get_data_model_type()):
5555
raise TypeError(
5656
f"Converter of type {self.__class__} can only convert objects of type "

src/spdx_tools/spdx/jsonschema/creation_info_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def get_json_type(self) -> Type[JsonProperty]:
1919
return CreationInfoProperty
2020

2121
def _get_property_value(
22-
self, creation_info: CreationInfo, creation_info_property: CreationInfoProperty, _document: Document = None
22+
self, creation_info: CreationInfo, creation_info_property: CreationInfoProperty, _document: Document | None = None
2323
) -> Any:
2424
if creation_info_property == CreationInfoProperty.CREATED:
2525
return datetime_to_iso_string(creation_info.created)

src/spdx_tools/spdx/jsonschema/document_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def json_property_name(self, document_property: DocumentProperty) -> str:
5050
return super().json_property_name(document_property)
5151

5252
def _get_property_value(
53-
self, document: Document, document_property: DocumentProperty, _document: Document = None
53+
self, document: Document, document_property: DocumentProperty, _document: Document | None = None
5454
) -> Any:
5555
if document_property == DocumentProperty.SPDX_ID:
5656
return document.creation_info.spdx_id

src/spdx_tools/spdx/jsonschema/external_document_ref_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _get_property_value(
2020
self,
2121
external_document_ref: ExternalDocumentRef,
2222
external_document_ref_property: ExternalDocumentRefProperty,
23-
_document: Document = None,
23+
_document: Document | None = None,
2424
) -> Any:
2525
if external_document_ref_property == ExternalDocumentRefProperty.EXTERNAL_DOCUMENT_ID:
2626
return external_document_ref.document_ref_id

src/spdx_tools/spdx/jsonschema/external_package_ref_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _get_property_value(
1414
self,
1515
external_ref: ExternalPackageRef,
1616
external_ref_property: ExternalPackageRefProperty,
17-
document: Document = None,
17+
document: Document | None = None,
1818
) -> Any:
1919
if external_ref_property == ExternalPackageRefProperty.COMMENT:
2020
return external_ref.comment

src/spdx_tools/spdx/jsonschema/extracted_licensing_info_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _get_property_value(
1515
self,
1616
extracted_licensing_info: ExtractedLicensingInfo,
1717
extracted_licensing_info_property: ExtractedLicensingInfoProperty,
18-
document: Document = None,
18+
document: Document | None = None,
1919
) -> Any:
2020
if extracted_licensing_info_property == ExtractedLicensingInfoProperty.COMMENT:
2121
return extracted_licensing_info.comment

src/spdx_tools/spdx/jsonschema/file_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def json_property_name(self, file_property: FileProperty) -> str:
2525
return "SPDXID"
2626
return super().json_property_name(file_property)
2727

28-
def _get_property_value(self, file: Any, file_property: FileProperty, document: Document = None) -> Any:
28+
def _get_property_value(self, file: Any, file_property: FileProperty, document: Document | None = None) -> Any:
2929
if file_property == FileProperty.SPDX_ID:
3030
return file.spdx_id
3131
elif file_property == FileProperty.ANNOTATIONS:

src/spdx_tools/spdx/jsonschema/package_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def json_property_name(self, package_property: PackageProperty) -> str:
3333
return super().json_property_name(package_property)
3434

3535
def _get_property_value(
36-
self, package: Package, package_property: PackageProperty, document: Document = None
36+
self, package: Package, package_property: PackageProperty, document: Document | None = None
3737
) -> Any:
3838
if package_property == PackageProperty.SPDX_ID:
3939
return package.spdx_id

0 commit comments

Comments
 (0)