
    +jg                        U d Z ddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl	m
Z
mZmZmZmZmZmZ ddlZddlZddlZddlmZ ddlmZ  ej        d          Zeee
f         Zeed<    G d d	e          Zd
eee
e
f                  dee         de
ddfdZ ddd
e
dee         de
de
fdZ!d
e
deeef         ddfdZ"d
e
dee         dee         de#de$e         ddfdZ%dFdede&defdZ'dGde(de&de
fd Z)d!e*de&fd"Z+d#e
d$eee(f         ddfd%Z, e	j-        d&d'(          Z.dd)d*d+d,dd-de
d.e#d/e#d0e#d1e#d2e#d3eee#                  defd4Z/de
d.e#d/e#d0e#d1e#d2e#d3ee#         defd5Z0 G d6 d'ej1                  Z1 G d7 d8eej2                  Z3defd9Z4d
eee(f         deee(f         fd:Z5d;edeed<e
f         ged<e
f         f         fd=Z6d>edefd?Z7d@edAedefdBZ8d@edAeddfdCZ9de
dDe*ej1                 de&fdEZ:dS )HzCommon utilities for the SDK.    N)AnyCallable	FrozenSetOptionalUnionget_args
get_origin)alias_generators)	TypeAliaszgoogle_genai._common
StringDictc                       e Zd ZdZdS )ExperimentalWarningz"Warning for experimental features.N)__name__
__module____qualname____doc__     X/home/wildlama/visual-decline/.venv/lib/python3.11/site-packages/google/genai/_common.pyr   r   &   s        ****r   r   datakeysvaluereturnc           	         |dS t          |dd                   D ]p\  }}|                    d          r|dd         }| X|| vrTt          |t                    r*d t	          t          |                    D             | |<   nt          d| d|           t          |t                    r@| >t          | |                   D ]'\  }}t          |||dz   d         ||                    (n)| '| |         D ]}t          |||dz   d         |            dS |                    d	          rC|dd
         }| 
|| vri g| |<   | (t          | |         d         ||dz   d         |            dS | |                     |i           } r| | 	                    |d                   }|l|sdS ||k    rdS t          |t                    r,t          |t                    r|                    |           dS t          d|d          d| d| d          |d         dk    rAt          | t                    r,t          |t                    r|                     |           dS || |d         <   dS dS )a9  Examples:

  set_value_by_path({}, ['a', 'b'], v)
    -> {'a': {'b': v}}
  set_value_by_path({}, ['a', 'b[]', c], [v1, v2])
    -> {'a': {'b': [{'c': v1}, {'c': v2}]}}
  set_value_by_path({'a': {'b': [{'c': v1}, {'c': v2}]}}, ['a', 'b[]', 'd'], v3)
    -> {'a': {'b': [{'c': v1, 'd': v3}, {'c': v2, 'd': v3}]}}
  N[]c                     g | ]}i S r   r   ).0_s     r   
<listcomp>z%set_value_by_path.<locals>.<listcomp>=   s    :::1B:::r   zvalue z$ must be a list given an array path    [0]r   z+Cannot set value for an existing key. Key: z; Existing value: z; New value: ._self)	enumerateendswith
isinstancelistrangelen
ValueErrorset_value_by_path
setdefaultgetdictupdate)	r   r   r   ikeykey_namejdexisting_datas	            r   r.   r.   *   s$    ]
F$ss)$$ & &fa
||D SbSh		hd22eT"" 	::c%jj(9(9:::$x..GuGG#GG   
E4	 	  7T%5d8n-- 	8 	8DAq
AtAEGG}eAh
7
7
7
7	8 > 7 7aaa!egg6666ff	e		 SbSh		hd22X		$x.+T!a%'']EBBBff__S"%%d	HHT"X&&M   
M!! mT** 
z%/F/F 
U#####E$r( E E -E E<AE E E
 
 	
 r(g

t$$ %%  	ET"X; r   default_valuer:   c                   dgk    r| S t                    D ]\  }| sc S |                    d          r*|dd         }|| v rfd| |         D             c S c S |                    d          rE|dd         }|| v r3| |         r+t          | |         d         d	z   d         
          c S c S || v r	| |         } t          | t                    r!t          | |          rt          | |          } c S | S )zExamples:

  get_value_by_path({'a': {'b': v}}, ['a', 'b'])
    -> v
  get_value_by_path({'a': {'b': [{'c': v1}, {'c': v2}]}}, ['a', 'b[]', 'c'])
    -> [v1, v2]
  r&   r   Nr   c                 J    g | ]}t          |d z   d                    S )r"   Nr9   )get_value_by_path)r   r7   r:   r3   r   s     r   r!   z%get_value_by_path.<locals>.<listcomp>   sD     
 
 
 aa!eggmLLL
 
 
r   r#   r$   r   r"   r9   )r'   r(   r=   r)   	BaseModelhasattrgetattr)r   r   r:   r4   r5   r3   s    ``  @r   r=   r=   t   s    
gYK$  fa 
||D SbSh	T		
 
 
 
 
 
(^
 
 
 	
 	
 	

 	e		 SbSh	T		d8n	 N1tAEGG}M
 
 
 	
 	
 	
 	CydI&& 74+=+= tS!!	+r   pathsc                    |                                 D ]\  }}|                    d          }|                    d          }t                      }d}t          |          D ]\  }}	|	dk    r|} n|dk    rt	          |          |k    rmt          |t	          |                    D ]O}||         }	|	dk    r?|	                    d          s*|	                    d          s|                    |	           Pt          | ||d|           dS )a#  Moves values from source paths to destination paths.

  Examples:
    move_value_by_path(
      {'requests': [{'content': v1}, {'content': v2}]},
      {'requests[].*': 'requests[].request.*'}
    )
      -> {'requests': [{'request': {'content': v1}}, {'request': {'content':
      v2}}]}
  r%   r   *r   r#   r   N)	itemssplitsetr'   r,   r+   r(   add_move_value_recursive)
r   rA   source_path	dest_pathsource_keys	dest_keysexclude_keyswildcard_idxr3   r4   s
             r   move_value_by_pathrO      s5    !& I Ik9##C((K$$I 55LLK((  3	 
 rc)nn|;; \3y>>22    !l#::cll400:e9L9L:


3


 $Y<HHHH-I Ir   rK   rL   key_idxrM   c                     |t          |          k    rdS ||         }|                    d          rP|dd         }| v r<t           |         t                    r# |         D ]}t	          ||||dz              dS dS dS |dk    rt           t
                    rfdt                                                     D             } fd|D             }	|	                                D ]V\  }
}g }||d         D ]3}|dk    r|                    |
           |                    |           4t           ||           W|D ]}
 |
= dS dS | v rt	           |         |||dz              dS dS )z>Recursively moves values from source path to destination path.Nr   r   r"   rC   c                 F    g | ]}|                     d           s|v|S )r    )
startswith)r   krM   s     r   r!   z)_move_value_recursive.<locals>.<listcomp>   sD       c"" ()'<'< '<'<'<r   c                 "    i | ]}||         S r   r   )r   rT   r   s     r   
<dictcomp>z)_move_value_recursive.<locals>.<dictcomp>   s    999q47999r   )
r,   r(   r)   r*   rH   r1   r   rD   appendr.   )r   rK   rL   rP   rM   r4   r5   itemkeys_to_movevalues_to_moverT   vnew_dest_keysdks   `   `         r   rH   rH      s!    K    
FG#\\$ (3B3xH4JtH~t<<x. 
 
$+y'A+|	
 	
 	
 	
 
 
 czz$    		$$  l :999L999n !&&(( 2 2$!QGHH% 	% 	%B3YY  ####  $$$$$q1111   !GG1 .  d{{
s)[)Wq[,     {r   T	snake_strconvertc                 8    |s| S t          j        dd |           S )z>Converts a snake_case string to CamelCase, if convert is True.z_([a-zA-Z])c                 P    |                      d                                          S )Nr"   )groupupper)matchs    r   <lambda>z&maybe_snake_to_camel.<locals>.<lambda>   s    ekk!nn.B.B.D.D r   )resub)r^   r_   s     r   maybe_snake_to_camelrh      s(    	 	 D Di	P	PPr   Fobjconvert_keysc                 4   t          | t          j                  r$t          |                     d                    S t          | t
                    r fd|                                 D             S t          | t                    rfd| D             S | S )a  Recursively converts a given object to a dictionary.

  If the object is a Pydantic model, it uses the model's `model_dump()` method.

  Args:
    obj: The object to convert.
    convert_keys: Whether to convert the keys from snake case to camel case.

  Returns:
    A dictionary representation of the object, a list of objects if a list is
    passed, or the object itself if it is not a dictionary, list, or Pydantic
    model.
  T)exclude_nonec                 R    i | ]#\  }}t          |          t          |          $S r   )rh   convert_to_dict)r   r4   r   rj   s      r   rV   z#convert_to_dict.<locals>.<dictcomp>  sA       C 	S,//1G1G  r   c                 0    g | ]}t          |          S r   )rn   )r   rX   rj   s     r   r!   z#convert_to_dict.<locals>.<listcomp>  s#    @@@DOD,//@@@r   )r)   pydanticr>   rn   
model_dumpr1   rD   r*   )ri   rj   s    `r   rn   rn     s     X'(( 
3>>t><<lKKK#t    ))++    #t @@@@C@@@@Jr   
annotationc                 J   t          |           }t          |           }|t          urdS |rt          |          dk    rdS |d         }t          |          }t          |          }|t          urdS |rt          |          dk    rdS |\  }}|t
          u o|t          j        u S )zChecks if the given annotation is list[dict[str, typing.Any]]

  or typing.List[typing.Dict[str, typing.Any]].

  This maps to Struct type in the API.
  Fr"   r      )r	   r   r*   r,   r1   strtypingr   )rr   outer_origin
outer_argsinner_annotationinner_origin
inner_argskey_type
value_types           r   _is_struct_typer~     s     J'',
##*5	 s:!++5],--,())*5	 s:!++5 $(J	S	5Z6:55r   modelresponsec                    t          |                                          }|D ]R\  }}d | j                                        D             }|| j        vr||vr|                    |           L|                    ||          }| j        |         j        }t          j        |          t          u rt          j	        |          d         }t          |t                    r,t          j        |          t          urt          ||           t          |t                     rSt          |          r|D ]?}t          |t                    r(t          t          j	        |          d         |           @TdS )zfRemoves extra fields from the response that are not in the model.

  Mutates the response in place.
  c                 $    i | ]\  }}|j         |S r   )alias)r   r4   
field_infos      r   rV   z(_remove_extra_fields.<locals>.<dictcomp>H  s.       "1#z
#  r   r   N)r*   rD   model_fieldspopr0   rr   rv   r	   r   r   r)   r1   _remove_extra_fieldsr~   )r   r   
key_valuesr4   r   	alias_maprr   rX   s           r   r   r   =  s    HNN$$%%* E Ejc5 5:5G5M5M5O5O  I %$$$I)=)=ll3
--S
!
!C#C(3J $$--?:..q1j % 	E6#4Z#@#@#L#L:u----	E4	 	  E		$	$  E E$dD!! 	E
vz::1=t
D
D
D=E Er   Tr>   )boundrt   d         indent_levelindent_deltamax_len	max_itemsdepthvisitedr   r   r   r   r   r   c          
      Z   |t                      }t          |           }||v rdS |dk     rdS t          t          |          |gz             }d|z  }d||z   z  }	t          | t          j                  r| j        j        }
g }t          t          |           j
                  }|D ]}t          |           j
        |         }|j        s$	 t          | |          }n# t          $ r Y Bw xY w|It          |||z   ||||dz
  |          }|                    |	 | d|            |s|
 d	S |
 d
d                    |          z   d| dz   S t          | t"                    r/d| v r|                     dd          }d| dS t          |           S t          | t&                    rGt)          |           |k    r%t          | d|dz
                     dd          dS t          |           S t          | t*          j        j                  r<| sdS |dk    r/t)          |            dt)          |           dk    rdnd }d| dS t)          |           |k    rdt)          |            dS g }	 t          |                                 t"                    }n1# t2          $ r$ t          |                                           }Y nw xY w|D ]^}| |         }t          |||z   ||||dz
  |          }t          |||z   ||||dz
  |          }|                    |	 | d|            _dd                    |          z   d| dz   S t          | t          t4          t6          f          rt9          | ||||||          S t          |           }|                    dd|	           S )z-Returns a representation of the given object.Nz<... Circular reference ...>r   z<... Max depth ...> r"   r   =z()z(
,

)z"""z\"\"\"   r   z...'z{} items z{<... z at Max depth ...>}z
<dict len=>)r4   z: z{
})	frozensetidr*   r)   rp   r>   	__class__r   sortedtyper   reprr@   AttributeError_pretty_reprrW   joinru   replacebytesr,   collectionsabcMappingr   	TypeErrortuplerF   _format_collection)ri   r   r   r   r   r   r   obj_idindentnext_indent_strcls_namerD   fields
field_namer   r   
value_represcapeditem_count_strsorted_keysrT   r[   k_reprv_reprraw_reprs                            r   r   r   i  s    _kkGc77&w))
QYY  d7mmvh.//'&<,67/X'(( a:}%HEDII*++F B B
99)*5j_ Z((    

#l2#	  j llo@z@@J@@AAAA ___ejj///.v...@@#s @:s{{E;//g799#u ::
3xx'S'!)_%%crc*000099#{.// 6: T zzc((GGCA2GGn;~;;;;
3xx)%#c((%%%%E%388::3///kk % % %$$kkk%  ; ;
a&a
#l2#	  f 
#l2#	  f llo9v9999::::UZZ&&&f88#eS)** :!!    CyyHD"8"8"8999s$   C
C)(C)3(J +K
	K
c                   t          | t                    rd}| }nrt          | t                    rd}t          |           }nKt          | t                    rt          |           }| rd}n"d}nt	          dt          |                      |s|d         |d         z   S |dk    r>t          |           dd	t          |          dk    z   }	|d          d
|	 d|d          S d|z  }
d||z   z  }g }t          t          |          |          }t          |          D ]<}||         }|	                    |t          |||z   ||||dz
  |          z              =t          |          |k    r+|	                    | d
t          |          |z
   d           |d          dd                    |          z   d|
 |d          z   S )z(Formats a collection (list, tuple, set).)[])(r   ){r   )zset(r   zUnsupported collection type: r   r"   r   r   z<... z at Max depth ...>r   r   z more items ...>r   r   )r)   r*   r   rF   r-   r   r,   minr+   rW   r   r   )ri   r   r   r   r   r   r   bracketsinternal_objr   r   r   elementsnum_to_showr3   elems                   r   r   r     sA    T BHLL#u 
BH99LL#s B99L
 hhhh
@T#YY@@
A
AA	 %A;!$$ aZZL))LLS5F5F5I0JLLNqkOOOO(1+OOO&<,67/(C%%y11+  a?DOO
%4%!)
 
 
		
    	""OOPP\!2!2Y!>PPP   QK			ejj22	25P65P8A;5P5P	PPr   c                   4    e Zd Z ej        ej        dddddddej        f	  	        Z	 ej
        d          eded	efd
                        Zd	ef fdZedej        e         deeef         deeef         d	efd            Zd	eeef         fdZ xZS )r>   Tr   forbidbase64)	alias_generatorpopulate_by_namefrom_attributesprotected_namespacesextraarbitrary_types_allowedser_json_bytesval_json_bytesignored_typesbefore)moder   r   c                 
   t          |t          t          j        f          s|S | j                                        D ]D\  }}t          |t                    r|                    |          }nt          ||d          }|E|j        }t          |          }|t          u r6t          |          }d |D             }t          |          dk    r|d         }t          |t                    rt          |          t          |t          j                  rlt          |t          j                  rRt          ||          sBt                              d| j         d| d|j         dt          |          j                    F|S )	zFCheck for type mismatches and warn before Pydantic processes the data.Nc                 4    g | ]}|t          d           u|S N)r   )r   args     r   r!   z:BaseModel._check_field_type_mismatches.<locals>.<listcomp>J  s(    GGG#DJJ1F1F#1F1F1Fr   r"   r   zType mismatch in r%   z: expected z, got )r)   r1   rp   r>   r   rD   r0   r@   rr   r	   r   r   r,   r   
issubclassloggerwarningr   )	clsr   r   r   r   expected_typeoriginargsnon_none_typess	            r   _check_field_type_mismatchesz&BaseModel._check_field_type_mismatches4  s   
 dT8#5677 k"%"2"8"8":": 
 

J	D$		 0$$j$//	 +m-((f	5&&GGGGG~!##(+-
]D
)
) 

]
#
#
+
]H$6
7
7 ,
UH.
/
/ , .. , 	M M Mz M M%.M M6:5kk6JM M	
 	
 	

 Kr   c                     	 t          |           S # t          $ r# t                                                      cY S w xY wr   )r   	Exceptionsuper__repr__)selfr   s    r   r   zBaseModel.__repr__Z  sM     $      WW s    *??r   r   kwargsc                    |d uo@d|v o<|d         d uo2t          |d         t                    od|d         v o|d         d         }|st          | |           |                     |          }|S )Nconfiginclude_all_fields)r)   r1   r   model_validate)r   r   r   should_skip_removing_fieldsvalidated_responses        r   _from_responsezBaseModel._from_response`  s     	d 	3	38D(	3 vh'..	3 !F8$44		3
 812   ' *3)))++H55r   c                 0    |                      dd          S )NTjson)rl   r   )rq   )r   s    r   to_json_dictzBaseModel.to_json_dict|  s    ??6?:::r   )r   r   r   rp   
ConfigDictr
   to_camelrv   TypeVarmodel_configmodel_validatorclassmethodr   r   ru   r   Typer   r1   objectr   r   __classcell__r   s   @r   r>   r>   %  sL       $$&/"^%  , 8***"c "c " " " ; +*"H              ;q> S&[! 3;	
 	   ;6;Df- ; ; ; ; ; ; ; ;r   c                   <     e Zd ZdZededef fd            Z xZS )CaseInSensitiveEnumzCase insensitive enum.r   r   c                    	 | |                                          S # t          $ r 	 | |                                         cY S # t          $ rm t          j        | d| j                    	 t                                          | |          }t          |          |_	        ||_
        |cY cY S #  Y Y Y d S xY ww xY ww xY w)Nz is not a valid )rc   KeyErrorlowerwarningswarnr   r   __new__ru   _name__value_)r   r   unknown_enum_valr   s      r   	_missing_zCaseInSensitiveEnum._missing_  s       5;;==!!!! 
 
 
>>>>???	 #WW__S%88
$'JJ

!%*

"!
!
!
!
!
!	
sJ    
B?AB?(B;->B0+B;,B?0B72B;3B?7B;;B?)r   r   r   r   r   r   r  r   r   s   @r   r  r    s[        C C      ;    r   r  c                      t           j                                                             d          } t          j                    j        dd         }|  d| S )z]Composes a timestamped unique name.

  Returns:
      A string representing a unique name.
  z%Y%m%d%H%M%Sr   r   r    )datetimenowstrftimeuuiduuid4hex)	timestamp	unique_ids     r   timestamped_unique_namer    sQ     ##%%..~>>)jllqs#)	#	#		#	##r   c                    i }t          | t                    s| S |                                 D ]\  }}t          |t                    r+t	          j        |                              d          ||<   Ft          |t          j                  r|                                ||<   xt          |t                    rt          |          ||<   t          |t                    rct          d |D                       rd |D             ||<   t          d |D                       rd |D             ||<   d |D             ||<   |||<   |S )a  Converts unserializable types in dict to json.dumps() compatible types.

  This function is called in models.py after calling convert_to_dict(). The
  convert_to_dict() can convert pydantic object to dict. However, the input to
  convert_to_dict() is dict mixed of pydantic object and nested dict(the output
  of converters). So they may be bytes in the dict and they are out of
  `ser_json_bytes` control in model_dump(mode='json') called in
  `convert_to_dict`, as well as datetime deserialization in Pydantic json mode.

  Returns:
    A dictionary with json.dumps() incompatible type (e.g. bytes datetime)
    to compatible type (e.g. base64 encoded string, isoformat date string).
  asciic              3   @   K   | ]}t          |t                    V  d S r   )r)   r   r   r[   s     r   	<genexpr>z.encode_unserializable_types.<locals>.<genexpr>  s,      11aZ5!!111111r   c                 \    g | ])}t          j        |                              d           *S )r  )r   urlsafe_b64encodedecoder  s     r   r!   z/encode_unserializable_types.<locals>.<listcomp>  s>     
 
 
<=F$Q''..w77
 
 
r   c              3   J   K   | ]}t          |t          j                  V  d S r   )r)   r  r  s     r   r  z.encode_unserializable_types.<locals>.<genexpr>  s/      ==!Z8,--======r   c                 6    g | ]}|                                 S r   )	isoformatr  s     r   r!   z/encode_unserializable_types.<locals>.<listcomp>  s     <<<q{{}}<<<r   c                 ,    g | ]}t          |          S r   )encode_unserializable_typesr  s     r   r!   z/encode_unserializable_types.<locals>.<listcomp>  s!    MMM!:1==MMMr   )r)   r1   rD   r   r   r  r  r  r   r"  r*   all)r   processed_datar4   r   s       r   r"  r"    s    ').	D$		 KJJLL " "jc5% ""4U;;BB7KKnS	E8,	-	- "!OO--nS	E4	 	  "7>>nS	E4	 	  
"	115111	1	1 

 
AF
 
 
s 
==u===	=	= N<<e<<<sMMuMMMs!nS	r   message.c                 d     dt           dt          f         dt           dt          f         f fd}|S )z&Experimental warning, only warns once.func.r   c                 ~     dt          j                   dt          dt          dt          f fd            }|S )NFr   r   r   c                  T    sdt          j        t          d            | i |S )NTrt   )r%  category
stacklevel)r  r  r   )r   r   r'  r%  warning_dones     r   wrapperz8experimental_warning.<locals>.decorator.<locals>.wrapper  sK      
(	
 	
 	
 	

 T4"6"""r   )	functoolswrapsr   )r'  r-  r,  r%  s   ` @r   	decoratorz'experimental_warning.<locals>.decorator  sc    L_T	#s 	#c 	#c 	# 	# 	# 	# 	# 	# 	# 	# Nr   )r   r   )r%  r0  s   ` r   experimental_warningr1    sI    
hsCx( Xc3h-?      " 
r   key_strc                 R    |                      dd                                          S )z?Normalizes a key for case-insensitive and snake/camel matching.r    r   )r   r  )r2  s    r   _normalize_key_for_matchingr4    s"    	b	!	!	'	'	)	))r   target_dictupdate_dictc                    i }d |                                  D             }|                                D ]\  }}t          |          }||v r	||         }n|}t          |t                    rBt          |                     |          t                    rt          | |         |          ||<   zt          |t                    r.t          |                     |          t                    r|||<   |||<   |S )a  Aligns the keys of update_dict to the case of target_dict keys.

  Args:
      target_dict: The dictionary with the target key casing.
      update_dict: The dictionary whose keys need to be aligned.

  Returns:
      A new dictionary with keys aligned to target_dict's key casing.
  c                 .    i | ]}t          |          |S r   )r4  )r   r4   s     r   rV   z"align_key_case.<locals>.<dictcomp>  s0       03!#&&  r   )r   rD   r4  r)   r1   r0   align_key_caser*   )r5  r6  aligned_update_dicttarget_keys_mapr4   r   normalized_update_keyaligned_keys           r   r9  r9    s2    %' 7B7G7G7I7I  /  %%'' / /jc57<<//#$9:kkk% /:$$d$ $ / *8
k
"E* *+&& 
E4	 	  /Z$$d& & / */+&&).+&&	r   c                    t          | |          }|                                D ]\  }}|| v rGt          | |         t                    r,t          |t                    rt	          | |         |           P|| v rmt          | |         t          |                    sJt                              d| dt          | |                    dt          |           d           || |<   || |<   dS )a  Recursively updates a target dictionary with values from an update dictionary.

  We don't enforce the updated dict values to have the same type with the
  target_dict values except log warnings.
  Users providing the update_dict should be responsible for constructing correct
  data.

  Args:
      target_dict (dict): The dictionary to be updated.
      update_dict (dict): The dictionary containing updates.
  zType mismatch for key 'z'. Existing type: z, new type: z. Overwriting.N)r9  rD   r)   r1   recursive_dict_updater   r   r   )r5  r6  r:  r4   r   s        r   r?  r?    s-   $ '{K@@'--//  jc5{{3'.. 	ud## 	 K,e4444			J{3/?e$M$M	nnNC N N;s#$$N N26u++N N N   k#k# r   r   c                 d    t           t                    st          |d          sdS t           fd|j        D                       }|sdt           t
          j                  rJ	  |            t          fdt                     j        D                       }n# t          $ r Y dS w xY w|S )a  Checks if an object has all of the fields of a Pydantic model.

  This is a duck-typing alternative to `isinstance` to solve dual-import
  problems. It returns False for dictionaries, which should be handled by
  `isinstance(obj, dict)`.

  Args:
    obj: The object to check.
    cls: The Pydantic model class to duck-type against.

  Returns:
    True if the object has all the fields defined in the Pydantic model, False
    otherwise.
  r   Fc              3   8   K   | ]}t          |          V  d S r   r?   )r   fieldri   s     r   r  z"is_duck_type_of.<locals>.<genexpr>F  s-      FFEGC''FFFFFFr   c              3   8   K   | ]}t          |          V  d S r   rB  )r   fobj_privates     r   r  z"is_duck_type_of.<locals>.<genexpr>L  s-      PPAQ//PPPPPPr   )	r)   r1   r?   r#  r   rp   r>   r   r-   )ri   r   all_matchedrF  s   `  @r   is_duck_type_ofrH  3  s     T '#~">"> 5 FFFFS5EFFFFF+	 C);<< CEEkPPPPc9OPPPPPkk   UU	s   '7B 
B-,B-)T)F);r   r   collections.abcr   r  enumr.  loggingrf   rv   r   r   r   r   r   r   r	   r  r  rp   r
   typing_extensionsr   	getLoggerr   r1   ru   r   __annotations__Warningr   r*   r.   r=   rO   intrF   rH   boolrh   r   rn   r   r~   r   r   r   r   r   r>   Enumr  r  r"  r1  r4  r9  r?  rH  r   r   r   <module>rS     s    $ # #             				  R R R R R R R R R R R R R R R R R R    % % % % % % ' ' ' ' ' '		1	2	2S#X
I & & &+ + + + +' + + +G
4S>
"G*.s)G<?G	G G G GV 9=' ' '
'#Y'25'' ' ' 'T!IS !Ic3h !ID !I !I !I !IH5
5c5 Cy5 	5
 c(5 
5 5 5 5pQ QC Q$ Q# Q Q Q Q  t     66 6 6 6 6 6B&E &EtCK/@ &ET &E &E &E &ER FN3k*** (,{: {: {:	{: {: 	{:
 {: {: {: in%{: 	{: {: {: {:|;Q	;Q ;Q 	;Q
 ;Q ;Q ;Q s^;Q 	;Q ;Q ;Q ;Q|X; X; X; X; X;" X; X; X;v    #ty   .$ $ $ $ $#d3;&7 #Df<M # # # #LxS!"HS#X$667   2* * * * * *
&&*4&& & & &R!!*4!	! ! ! !H 4(:#;       r   