@@ -156,7 +156,7 @@ def _extract_user_message_example(self, flow: Flow) -> None:
156156 # The SpecOp.spec type is Union[Spec, dict]. Convert Dict to Spec if it's provided
157157 match_spec : Spec = (
158158 spec_op .spec
159- if type (spec_op .spec ) == Spec
159+ if isinstance (spec_op .spec , Spec )
160160 else Spec (** cast (Dict , spec_op .spec ))
161161 )
162162
@@ -179,7 +179,7 @@ def _extract_user_message_example(self, flow: Flow) -> None:
179179 # which isn't in the Spec definition
180180 await_spec_dict : Dict [str , Any ] = (
181181 asdict (spec_op .spec )
182- if type (spec_op .spec ) == Spec
182+ if isinstance (spec_op .spec , Spec )
183183 else cast (Dict , spec_op .spec )
184184 )
185185
@@ -213,15 +213,15 @@ def _extract_bot_message_example(self, flow: Flow):
213213
214214 el = flow .elements [1 ]
215215
216- if type (el ) != SpecOp :
216+ if not isinstance (el , SpecOp ) :
217217 return
218218
219219 spec_op : SpecOp = cast (SpecOp , el )
220220 spec : Dict [str , Any ] = (
221221 asdict (
222222 spec_op .spec
223- ) # TODO! Refactor thiss function as it's duplicated in many places
224- if type (spec_op .spec ) == Spec
223+ ) # TODO! Refactor this function as it's duplicated in many places
224+ if isinstance (spec_op .spec , Spec )
225225 else cast (Dict , spec_op .spec )
226226 )
227227
@@ -241,7 +241,7 @@ def _process_flows(self):
241241 """Process the provided flows to extract the user utterance examples."""
242242 # Flows can be either Flow or Dict. Convert them all to Flow for following code
243243 flows : List [Flow ] = [
244- cast (Flow , flow ) if type (flow ) == Flow else Flow (** cast (Dict , flow ))
244+ cast (Flow , flow ) if isinstance (flow , Flow ) else Flow (** cast (Dict , flow ))
245245 for flow in self .config .flows
246246 ]
247247
0 commit comments