fix: Typing on recent mypy

pull/665/head
Raphaël Vinot 2020-11-25 13:19:19 +01:00
parent d06313a653
commit f254e15bd4
2 changed files with 8 additions and 7 deletions

View File

@ -60,9 +60,10 @@ def get_uuid_or_id_from_abstract_misp(obj: Union[AbstractMISP, int, str, UUID])
if isinstance(obj, MISPOrganisationBlocklist):
return obj.org_uuid
if 'uuid' in obj:
return obj['uuid']
return obj['id']
# at this point, we must have an AbstractMISP
if 'uuid' in obj: # type: ignore
return obj['uuid'] # type: ignore
return obj['id'] # type: ignore
def register_user(misp_url: str, email: str,

View File

@ -6,7 +6,7 @@ import json
import os
import base64
import sys
from io import BytesIO, IOBase
from io import BytesIO, RawIOBase
from zipfile import ZipFile
import uuid
from collections import defaultdict
@ -1150,9 +1150,9 @@ class MISPEvent(AbstractMISP):
def load(self, json_event: Union[IO, str, bytes, dict], validate: bool = False, metadata_only: bool = False):
"""Load a JSON dump from a pseudo file or a JSON string"""
if isinstance(json_event, IOBase):
# python2 and python3 compatible to find if we have a file
json_event = json_event.read()
if isinstance(json_event, RawIOBase):
json_event = json_event.read() # type: ignore
if isinstance(json_event, (str, bytes)):
json_event = json.loads(json_event)