File tree Expand file tree Collapse file tree 4 files changed +498
-323
lines changed Expand file tree Collapse file tree 4 files changed +498
-323
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,13 @@ def __init__(
2525
2626 @classmethod
2727 def from_dict (cls , d : Dict [str , any ]) -> "ErrorDetail" :
28- if "@type" in d :
29- d ["type" ] = d ["@type" ]
30- return cls (** d )
28+ # Key "@type" is not a valid keyword argument name in Python. Rename
29+ # it to "type" to avoid conflicts.
30+ safe_args = {}
31+ for k , v in d .items ():
32+ safe_args [k if k != "@type" else "type" ] = v
33+
34+ return cls (** safe_args )
3135
3236
3337class DatabricksError (IOError ):
@@ -98,14 +102,16 @@ def __init__(
98102 super ().__init__ (message if message else error )
99103 self .error_code = error_code
100104 self .retry_after_secs = retry_after_secs
101-
102- parsed_details = [errdetails .parse_json_details (d ) for d in details ] if details else []
103- self ._error_details = errdetails .parse_error_details (parsed_details )
104-
105+ self ._error_details = errdetails .parse_error_details (details )
105106 self .kwargs = kwargs
106107
107108 # Deprecated.
108- self .details = [ErrorDetail .from_dict (d ) for d in details ] if details else []
109+ self .details = []
110+ if details :
111+ for d in details :
112+ if not isinstance (d , dict ):
113+ continue
114+ self .details .append (ErrorDetail .from_dict (d ))
109115
110116 def get_error_info (self ) -> List [ErrorDetail ]:
111117 return self ._get_details_by_type (errdetails ._ERROR_INFO_TYPE )
You can’t perform that action at this time.
0 commit comments