1
1
from collections import namedtuple
2
- from typing import Any , Dict , List , Optional
2
+ from typing import Any , Dict , List , Optional , MutableMapping
3
3
from typing_extensions import Text # pylint: disable=unused-import
4
4
# move to a regular typing import when Python 3.3-3.6 is no longer supported
5
5
15
15
16
16
def _get_type (tp ):
17
17
# type: (Any) -> Any
18
- if isinstance (tp , dict ):
18
+ if isinstance (tp , MutableMapping ):
19
19
if tp .get ("type" ) not in ("array" , "record" , "enum" ):
20
20
return tp ["type" ]
21
21
return tp
@@ -48,7 +48,7 @@ def merge_flatten_type(src):
48
48
49
49
if isinstance (src , list ):
50
50
return [merge_flatten_type (t ) for t in src ]
51
- if isinstance (src , dict ) and src .get ("type" ) == "array" :
51
+ if isinstance (src , MutableMapping ) and src .get ("type" ) == "array" :
52
52
return src
53
53
return {"items" : src , "type" : "array" }
54
54
@@ -65,7 +65,7 @@ def can_assign_src_to_sink(src, sink, strict=False): # type: (Any, Any, bool) -
65
65
66
66
if src == "Any" or sink == "Any" :
67
67
return True
68
- if isinstance (src , dict ) and isinstance (sink , dict ):
68
+ if isinstance (src , MutableMapping ) and isinstance (sink , MutableMapping ):
69
69
if sink .get ("not_connected" ) and strict :
70
70
return False
71
71
if src ["type" ] == "array" and sink ["type" ] == "array" :
0 commit comments