@@ -155,7 +155,7 @@ def _extract_user_message_example(self, flow: Flow) -> None:
155155 # The SpecOp.spec type is Union[Spec, dict]. Convert Dict to Spec if it's provided
156156 match_spec : Spec = (
157157 spec_op .spec
158- if type (spec_op .spec ) == Spec
158+ if isinstance (spec_op .spec , Spec )
159159 else Spec (** cast (Dict , spec_op .spec ))
160160 )
161161
@@ -178,7 +178,7 @@ def _extract_user_message_example(self, flow: Flow) -> None:
178178 # which isn't in the Spec definition
179179 await_spec_dict : Dict [str , Any ] = (
180180 asdict (spec_op .spec )
181- if type (spec_op .spec ) == Spec
181+ if isinstance (spec_op .spec , Spec )
182182 else cast (Dict , spec_op .spec )
183183 )
184184
@@ -212,15 +212,15 @@ def _extract_bot_message_example(self, flow: Flow):
212212
213213 el = flow .elements [1 ]
214214
215- if type (el ) != SpecOp :
215+ if not isinstance (el , SpecOp ) :
216216 return
217217
218218 spec_op : SpecOp = cast (SpecOp , el )
219219 spec : Dict [str , Any ] = (
220220 asdict (
221221 spec_op .spec
222- ) # TODO! Refactor thiss function as it's duplicated in many places
223- if type (spec_op .spec ) == Spec
222+ ) # TODO! Refactor this function as it's duplicated in many places
223+ if isinstance (spec_op .spec , Spec )
224224 else cast (Dict , spec_op .spec )
225225 )
226226
@@ -240,7 +240,7 @@ def _process_flows(self):
240240 """Process the provided flows to extract the user utterance examples."""
241241 # Flows can be either Flow or Dict. Convert them all to Flow for following code
242242 flows : List [Flow ] = [
243- cast (Flow , flow ) if type (flow ) == Flow else Flow (** cast (Dict , flow ))
243+ cast (Flow , flow ) if isinstance (flow , Flow ) else Flow (** cast (Dict , flow ))
244244 for flow in self .config .flows
245245 ]
246246
0 commit comments