2525"""
2626
2727# Standard library
28- from typing import List , Optional , Tuple
28+ from typing import List , Optional , Tuple , Union
2929import functools
3030
3131# Numpy (optional)
3737
3838# Javaobj
3939from .api import ObjectTransformer
40- from .beans import JavaInstance , JavaClassDesc
40+ from .beans import JavaInstance , JavaClassDesc , FieldType
4141from ..constants import TerminalCode , TypeCode
4242from ..utils import to_bytes , log_error , log_debug , read_struct , read_string
4343
@@ -238,7 +238,7 @@ def load_from_instance(self, indent=0):
238238 """
239239 # Lists have their content in there annotations
240240 for cd , annotations in self .annotations .items ():
241- if cd .name == self .HANDLED_CLASSES :
241+ if cd .name in self .HANDLED_CLASSES :
242242 # Annotation[1] == size of the set
243243 self .update (x for x in annotations [2 :])
244244 return True
@@ -254,7 +254,7 @@ class JavaTime(JavaInstance):
254254 parsed
255255 """
256256
257- HANDLED_CLASSES = "java.time.Ser"
257+ HANDLED_CLASSES = ( "java.time.Ser" ,) # type: Tuple[str, ...]
258258
259259 DURATION_TYPE = 1
260260 INSTANT_TYPE = 2
@@ -322,7 +322,7 @@ def load_from_instance(self, indent=0):
322322 """
323323 # Lists have their content in there annotations
324324 for cd , annotations in self .annotations .items ():
325- if cd .name == self .HANDLED_CLASSES :
325+ if cd .name in self .HANDLED_CLASSES :
326326 # Convert back annotations to bytes
327327 # latin-1 is used to ensure that bytes are kept as is
328328 content = to_bytes (annotations [0 ].data , "latin1" )
@@ -495,14 +495,14 @@ class NumpyArrayTransformer(ObjectTransformer):
495495 TypeCode .TYPE_BOOLEAN : ">B" ,
496496 }
497497
498- def load_array (self , reader , field_type , size ):
498+ def load_array (self , reader , type_code , size ):
499499 # type: (DataStreamReader, TypeCode, int) -> Optional[list]
500500 """
501501 Loads a Java array, if possible
502502 """
503503 if numpy is not None :
504504 try :
505- dtype = self .NUMPY_TYPE_MAP [field_type ]
505+ dtype = self .NUMPY_TYPE_MAP [type_code ]
506506 except KeyError :
507507 # Unhandled data type
508508 return None
0 commit comments