Skip to content

Commit 70af6e8

Browse files
committed
fix: [stix2 import] Making Python 3.9 happy with my return typings being str or None
1 parent aca3084 commit 70af6e8

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

misp_stix_converter/stix2misp/external_stix2_mapping.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from .. import Mapping
55
from .stix2_mapping import STIX2toMISPMapping
6+
from typing import Union
67

78

89
class ExternalSTIX2toMISPMapping(STIX2toMISPMapping):
@@ -122,13 +123,13 @@ def object_type_refs_to_skip(cls) -> tuple:
122123
return cls.__object_type_refs_to_skip
123124

124125
@classmethod
125-
def observable_mapping(cls, field: str) -> str | None:
126+
def observable_mapping(cls, field: str) -> Union[str, None]:
126127
return cls.__observable_mapping.get(field)
127128

128129
@classmethod
129130
def opinion_mapping(cls, field: str) -> int:
130131
return cls.__opinion_mapping.get(field, 50)
131132

132133
@classmethod
133-
def stix_object_loading_mapping(cls, field: str) -> str | None:
134+
def stix_object_loading_mapping(cls, field: str) -> Union[str, None]:
134135
return cls.__stix_object_loading_mapping.get(field)

misp_stix_converter/stix2misp/internal_stix2_mapping.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from .. import Mapping
55
from .stix2_mapping import STIX2toMISPMapping
6+
from typing import Union
67

78

89
class InternalSTIX2toMISPMapping(STIX2toMISPMapping):
@@ -30,5 +31,5 @@ def object_type_refs_to_skip(cls) -> tuple:
3031
return cls.__object_type_refs_to_skip
3132

3233
@classmethod
33-
def stix_object_loading_mapping(cls, field: str) -> str | None:
34+
def stix_object_loading_mapping(cls, field: str) -> Union[str, None]:
3435
return cls.__stix_object_loading_mapping.get(field)

misp_stix_converter/stix2misp/stix2_mapping.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from .. import Mapping
55
from abc import ABCMeta
6+
from typing import Union
67

78

89
class STIX2toMISPMapping(metaclass=ABCMeta):
@@ -103,15 +104,15 @@ class STIX2toMISPMapping(metaclass=ABCMeta):
103104
}
104105

105106
@classmethod
106-
def bundle_to_misp_mapping(cls, field: str) -> str | None:
107+
def bundle_to_misp_mapping(cls, field: str) -> Union[str, None]:
107108
return cls.__bundle_to_misp_mapping.get(field)
108109

109110
@classmethod
110-
def identity_references(cls, identity_id: str) -> str | None:
111+
def identity_references(cls, identity_id: str) -> Union[str, None]:
111112
return cls.__identity_references.get(identity_id)
112113

113114
@classmethod
114-
def marking_extension_mapping(cls, field: str) -> str | None:
115+
def marking_extension_mapping(cls, field: str) -> Union[str, None]:
115116
return cls.__marking_extension_mapping.get(field)
116117

117118
@classmethod
@@ -131,5 +132,5 @@ def stix_object_loading_mapping(cls) -> dict:
131132
return cls.__stix_object_loading_mapping
132133

133134
@classmethod
134-
def stix_to_misp_mapping(cls, field: str) -> str | None:
135+
def stix_to_misp_mapping(cls, field: str) -> Union[str, None]:
135136
return cls.__stix_to_misp_mapping.get(field)

0 commit comments

Comments
 (0)