Skip to content

Commit

Permalink
fix: [stix2 import] Making Python 3.9 happy with my return typings be…
Browse files Browse the repository at this point in the history
…ing str or None
  • Loading branch information
chrisr3d committed Mar 4, 2025
1 parent aca3084 commit 70af6e8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions misp_stix_converter/stix2misp/external_stix2_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .. import Mapping
from .stix2_mapping import STIX2toMISPMapping
from typing import Union


class ExternalSTIX2toMISPMapping(STIX2toMISPMapping):
Expand Down Expand Up @@ -122,13 +123,13 @@ def object_type_refs_to_skip(cls) -> tuple:
return cls.__object_type_refs_to_skip

@classmethod
def observable_mapping(cls, field: str) -> str | None:
def observable_mapping(cls, field: str) -> Union[str, None]:
return cls.__observable_mapping.get(field)

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

@classmethod
def stix_object_loading_mapping(cls, field: str) -> str | None:
def stix_object_loading_mapping(cls, field: str) -> Union[str, None]:
return cls.__stix_object_loading_mapping.get(field)
3 changes: 2 additions & 1 deletion misp_stix_converter/stix2misp/internal_stix2_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .. import Mapping
from .stix2_mapping import STIX2toMISPMapping
from typing import Union


class InternalSTIX2toMISPMapping(STIX2toMISPMapping):
Expand Down Expand Up @@ -30,5 +31,5 @@ def object_type_refs_to_skip(cls) -> tuple:
return cls.__object_type_refs_to_skip

@classmethod
def stix_object_loading_mapping(cls, field: str) -> str | None:
def stix_object_loading_mapping(cls, field: str) -> Union[str, None]:
return cls.__stix_object_loading_mapping.get(field)
9 changes: 5 additions & 4 deletions misp_stix_converter/stix2misp/stix2_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .. import Mapping
from abc import ABCMeta
from typing import Union


class STIX2toMISPMapping(metaclass=ABCMeta):
Expand Down Expand Up @@ -103,15 +104,15 @@ class STIX2toMISPMapping(metaclass=ABCMeta):
}

@classmethod
def bundle_to_misp_mapping(cls, field: str) -> str | None:
def bundle_to_misp_mapping(cls, field: str) -> Union[str, None]:
return cls.__bundle_to_misp_mapping.get(field)

@classmethod
def identity_references(cls, identity_id: str) -> str | None:
def identity_references(cls, identity_id: str) -> Union[str, None]:
return cls.__identity_references.get(identity_id)

@classmethod
def marking_extension_mapping(cls, field: str) -> str | None:
def marking_extension_mapping(cls, field: str) -> Union[str, None]:
return cls.__marking_extension_mapping.get(field)

@classmethod
Expand All @@ -131,5 +132,5 @@ def stix_object_loading_mapping(cls) -> dict:
return cls.__stix_object_loading_mapping

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

0 comments on commit 70af6e8

Please sign in to comment.