ó
    Ð]jÔ  ã                  óz  • S SK Jr  S SKrS SKJs  Jr  S SK	r	S SK
r
S SKrS SKJrJr  S SKJrJr  S SKJr  S SKJr  S SKJrJrJrJrJr  \S   r\(       a  S S	KJr  S SKrS S
K J!r!J"r"J#r#  S SK$J%r%  Sr&Sr'Sr(Sr)Sr*Sr+Sr,Sr-Sr.\" S5      r/\" SSS9r0\(       d  \
Rb                  S:  a  \r2S r " S S\35      r4 " S S\45      r5 " S S \45      r6\" SS!9 " S" S#\\0   5      5       r7\ " S$ S%5      5       r8\ " S& S'5      5       r9\ " S( S)5      5       r:\ " S* S+5      5       r;\ " S, S-5      5       r<\ " S. S/5      5       r=S>S0 jr>S?S1 jr?        S@S2 jr@      SAS3 jrA      SBS4 jrB      SCS5 jrCSDS6 jrD        SES8 jrE      SFS9 jrF        SGS: jrG " S; S7\5      rH\ " S< S=\H5      5       rIg)Hé    )ÚannotationsN)ÚABCÚabstractmethod)ÚMappingÚSequence)Ú	ExitStack)Ú	dataclass)ÚTYPE_CHECKINGÚAnyÚGenericÚLiteralÚTypeVar)ÚmergeÚreplace©ÚTypeAdapter)ÚVariableConfigÚVariablesConfigÚVariableTypeConfig)ÚVariablez[0mz[1mz[2mz[31mz[32mz[33mz[36mz[90m)ÚResolvedVariableÚSyncModeÚValidationReportÚVariableProviderÚNoOpVariableProviderÚVariableWriteErrorÚVariableNotFoundErrorÚVariableAlreadyExistsErrorÚTÚT_coT)Ú	covariant)é   é
   c                 ó<   • UR                  SS 5        [        U 0 UD6$ )NÚkw_only)ÚpopÚ
_dataclass)ÚargsÚkwargss     ÚW/home/mande/repo/quber/.venv/lib/python3.13/site-packages/logfire/variables/abstract.pyr	   r	   3   s    € Ø�J‰J�y $Ô'Ü˜tÐ. vÑ.Ð.ó    c                  ó   • \ rS rSrSrSrg)r   é8   z5Base exception for variable write operation failures.© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r.   r+   r*   r   r   8   s   † Ù?âr+   r   c                  ó   • \ rS rSrSrSrg)r   é>   z$Raised when a variable is not found.r.   Nr/   r.   r+   r*   r   r   >   s   † Ù.âr+   r   c                  ó   • \ rS rSrSrSrg)r   éD   z<Raised when trying to create a variable that already exists.r.   Nr/   r.   r+   r*   r   r   D   s   † ÙFâr+   r   )r%   c                  ó„   • \ rS rSr% SrS\S'    S\S'    S\S'    S	rS
\S'    S	rS\S'    S	rS\S'    S r	S r
SS jrSrg	)r   éJ   aÊ  Details about a variable resolution including value, label, version, and any errors.

This class can be used as a context manager. When used as a context manager, it
automatically sets baggage with the variable name and label, enabling downstream
spans and logs to be associated with the variable resolution that was active at the time.

Example:
    ```python skip="true"
    my_var = logfire.var(name='my_var', type=str, default='default')
    with my_var.get() as details:
        # Inside this context, baggage is set with:
        # logfire.variables.my_var = <label> (or '<code_default>' if no label)
        value = details.value
        # Any spans/logs created here will have the baggage attached
    ```
ÚstrÚnamer    Úvaluez„Literal['resolved', 'context_override', 'missing_config', 'unrecognized_variable', 'validation_error', 'other_error', 'no_provider']Ú_reasonNú
str | NoneÚlabelz
int | NoneÚversionzException | NoneÚ	exceptionc                ó"   • [        5       U l        g ©N)r   Ú_exit_stack©Úselfs    r*   Ú__post_init__ÚResolvedVariable.__post_init__t   s   € Ü$›;ˆÕr+   c           	     óÜ   • U R                   R                  5         SS KnU R                   R                  UR                  " S0 SU R
                   3U R                  =(       d    S0D65        U $ )Nr   zlogfire.variables.z<code_default>r.   )rF   Ú	__enter__ÚlogfireÚenter_contextÚset_baggager=   rA   )rH   rM   s     r*   rL   ÚResolvedVariable.__enter__w   s^   € Ø×Ñ×"Ñ"Ô$ãà×Ñ×&Ñ&Ø×ÒÑeÐ%7¸¿	¹	°{Ð#CÀTÇZÁZ×EcÐScÐ"dÑeô	
ð ˆr+   c                ó<   • U R                   R                  XU5        g rE   )rF   Ú__exit__)rH   Úexc_typeÚexc_valÚexc_tbs       r*   rR   ÚResolvedVariable.__exit__‚   s   € Ø×Ñ×!Ñ! (°VÕ<r+   )rF   )rS   ztype[BaseException] | NonerT   zBaseException | NonerU   r   ÚreturnÚNone)r0   r1   r2   r3   r4   Ú__annotations__rA   rB   rC   rI   rL   rR   r5   r.   r+   r*   r   r   J   sb   ‡ ñð" ƒIØ#ØƒKØ-ðó ð @ð €Eˆ:ÓØ1Ø€GˆZÓØ;Ø"&€IÐÓ&Ø8ò'ò	÷=r+   r   c                  óF   • \ rS rSr% SrS\S'   S\S'   S\S'   SrS	\S
'   Srg)ÚLabelCompatibilityé‰   z?Result of checking a label value's compatibility with a schema.r<   rA   Úserialized_valueÚboolÚis_compatibleNr@   Úerrorr.   )r0   r1   r2   r3   r4   rY   r`   r5   r.   r+   r*   r[   r[   ‰   s    ‡ áIàƒJØÓØÓØ€Eˆ:Ör+   r[   c                  óž   • \ rS rSr% SrS\S'   S\S'   SrS\S'   SrS\S	'   SrS
\S'   Sr	S\S'   Sr
S
\S'   SrS
\S'   SrS
\S'   SrS\S'   Srg)ÚVariableChangeé“   z-Represents a change to be made to a variable.r<   r=   Úchange_typeNzdict[str, Any] | NoneÚlocal_schemaÚserver_schemar@   Úinitial_valuezlist[LabelCompatibility] | NoneÚincompatible_labelsÚ	server_idÚlocal_descriptionÚserver_descriptionFr^   Údescription_differsr.   )r0   r1   r2   r3   r4   rY   re   rf   rg   rh   ri   rj   rk   rl   r5   r.   r+   r*   rb   rb   “   sg   ‡ á7à
ƒIØÓØ*.€LÐ'Ó.Ø+/€MÐ(Ó/Ø $€M�:Ó$Ø;?ÐÐ8Ó?Ø €IˆzÓ Ø$(Ð�zÓ(Ø%)Ð˜
Ó)Ø %Ð˜Ö%r+   rb   c                  óB   • \ rS rSr% SrS\S'   S\S'   \S
S j5       rSrg	)ÚVariableDiffé£   z7Represents the diff between local and server variables.zlist[VariableChange]Úchangesú	list[str]Úorphaned_server_variablesc                ó:   • [        S U R                   5       5      $ )z.Return True if there are any changes to apply.c              3  ó>   #   • U  H  oR                   S :g  v •  M     g7f©Ú	no_changeN©rd   ©Ú.0Úcs     r*   Ú	<genexpr>Ú+VariableDiff.has_changes.<locals>.<genexpr>­   s   é € ÐFº°A—=‘= KÖ/ºùó   ‚)Úanyrp   rG   s    r*   Úhas_changesÚVariableDiff.has_changesª   s   € ô ÑF¸¿ºÓFÓFÐFr+   r.   N©rW   r^   )	r0   r1   r2   r3   r4   rY   Úpropertyr   r5   r.   r+   r*   rn   rn   £   s%   ‡ áAà!Ó!Ø(Ó(àóGó óGr+   rn   c                  ó8   • \ rS rSr% SrS\S'   S\S'   S\S'   S	rg
)ÚLabelValidationErroré°   z9Represents a validation error for a specific label value.r<   Úvariable_namer@   rA   Ú	Exceptionr`   r.   N©r0   r1   r2   r3   r4   rY   r5   r.   r+   r*   r„   r„   °   s   ‡ áCàÓØÓØÖr+   r„   c                  ó8   • \ rS rSr% SrS\S'   S\S'   S\S'   Srg	)
ÚDescriptionDifferenceé¹   z=Represents a description difference between local and server.r<   r†   r@   rj   rk   r.   Nrˆ   r.   r+   r*   rŠ   rŠ   ¹   s   ‡ áGàÓØ!Ó!Ø"Ö"r+   rŠ   c                  ó„   • \ rS rSr% SrS\S'    S\S'    S\S'    S	\S
'    \SS j5       r\SS j5       rSS.SS jjr	Sr
g)r   éÂ   aš  Report of variable validation results.

This class contains the results of validating variable definitions against
a provider's configuration. It can be used to check for errors programmatically
or formatted for human-readable output.

Example:
    ```python skip="true"
    report = provider.validate_variables(variables)
    if not report.is_valid:
        print(report.format())
        sys.exit(1)
    ```
zlist[LabelValidationError]ÚerrorsÚintÚvariables_checkedrq   Úvariables_not_on_serverzlist[DescriptionDifference]Údescription_differencesc                ó$   • U R                   (       + $ )z/Return True if there are any validation errors.)Úis_validrG   s    r*   Ú
has_errorsÚValidationReport.has_errorsÜ   s   € ð —=‘=Ô Ð r+   c                óp   • [        U R                  5      S:H  =(       a    [        U R                  5      S:H  $ )zmReturn False if there are any validation errors or any variables not defined in the (possibly remote) config.r   )ÚlenrŽ   r‘   rG   s    r*   r”   ÚValidationReport.is_validá   s-   € ô �4—;‘;Ó 1Ñ$×O¬¨T×-IÑ-IÓ)JÈaÑ)OÐOr+   T)Úcolorsc               óø  • U(       a  [         OSnU(       a  [        OSnU(       a  [        OSnU(       a  [        OSnU(       a  [        OSn/ nU R
                  (       Ga  UR                  SU SU 35        U R
                   Hé  nUR                  c2  UR                  SU SUR                   SUR                   U 35        MB  UR                  SU SUR                   SUR                   S	U 35        [        UR                  5      R                  S5      n	U	SS
  H  n
UR                  SU
 35        M     [        U	5      S
:”  d  MÈ  UR                  S[        U	5      S
-
   S35        Më     U R                  (       aC  UR                  SU SU 35        U R                   H  nUR                  SU SU U 35        M     [        U R
                   Vs1 s H  oÌR                  iM     sn5      nU R                  U-
  [        U R                  5      -
  nUS:”  a  UR                  SU SU SU 35        U R                  (       aµ  UR                  SU SU 35        UR                  U SU 35        U R                   Hx  nUR                  SU SUR                   U 35        UR                   =(       d    SnUR"                  =(       d    SnUR                  SU 35        UR                  SU 35        Mz     U R$                  (       d3  U[        U R                  5      -   nUR                  SU SU SU 35        O$UR                  SU SU R                   SU 35        SR'                  U5      $ s  snf )z·Format the validation report for human-readable output.

Args:
    colors: If True, include ANSI color codes in output.

Returns:
    A formatted string representation of the report.
Ú Ú
z=== Validation Errors ===Nú  u   âœ— ú: z	 (label: Ú)é   z      z      ... (z more lines)z%=== Variables Not Found on Server ===ú? r   z=== Valid (ú variables) ===ú/=== Description differences (informational) ===úHNote: Different descriptions may be intentional for different codebases.ú! ú(none)ú    Local:  ú    Server: zValidation failed: z error(s) found.zValidation passed: All z variable(s) are valid.)Ú
ANSI_RESETÚANSI_REDÚ
ANSI_GREENÚANSI_YELLOWÚ	ANSI_CYANrŽ   ÚappendrA   r†   r`   r<   Úsplitr˜   r‘   r�   r’   rj   rk   r”   Újoin)rH   rš   ÚresetÚredÚgreenÚyellowÚcyanÚlinesr`   Úerror_linesÚliner=   ÚeÚvariables_with_errorsÚvalid_countÚdiffÚ
local_descÚserver_descÚerror_counts                      r*   ÚformatÚValidationReport.formatæ   s2  € ö %•
¨"ˆÞ �h bˆÞ$•
¨"ˆÞ &•¨BˆÞ"�y¨ˆàˆà�;�;ˆ;Ø�L‰L˜2˜c˜UÐ";¸E¸7ÐCÔDØŸœ�Ø—;‘;Ñ&Ø—L‘L 2 c U¨$¨u×/BÑ/BÐ.CÀ2ÀeÇkÁkÀ]ÐSXÐRYÐ!ZÖ[à—L‘L 2 c U¨$¨u×/BÑ/BÐ.CÀ9ÈUÏ[É[ÈMÐYZÐ[`ÐZaÐ!bÔcä"% e§k¡kÓ"2×"8Ñ"8¸Ó">�KØ +¨B¨Q£˜ØŸ™ v¨d¨V _Ö5ñ !0ä˜;Ó'¨!Õ+ØŸ™ {´3°{Ó3CÀaÑ3GÐ2HÈÐ%UÖVñ %ð ×'×'Ø�L‰L˜2˜f˜XÐ%JÈ5È'ÐRÔSØ×4Ô4�Ø—‘˜r & ¨¨D¨6°%°Ð9Ö:ñ 5ô !$¸d¿kºkÓ$Jºk¸§_¤_¹kÑ$JÓ KÐØ×,Ñ,Ð/DÑDÄsÈ4×KgÑKgÓGhÑhˆØ˜‹?Ø�L‰L˜2˜e˜W K°¨}¸OÈEÈ7ÐSÔTð ×'×'Ø�L‰L˜2˜d˜VÐ#RÐSXÐRYÐZÔ[Ø�L‰L˜D˜6Ð!iÐjoÐipÐqÔrØ×4Ô4�Ø—‘˜r $  r¨$×*<Ñ*<Ð)=¸e¸WÐEÔFØ!×3Ñ3×?°x�
Ø"×5Ñ5×A¸�Ø—‘˜|¨J¨<Ð8Ô9Ø—‘˜|¨K¨=Ð9Ö:ñ 5ð �}�}Ø/´#°d×6RÑ6RÓ2SÑSˆKØ�L‰L˜2˜c˜UÐ"5°k°]ÐBRÐSXÐRYÐZÕ[à�L‰L˜2˜e˜WÐ$;¸D×<RÑ<RÐ;SÐSjÐkpÐjqÐrÔsà�y‰y˜ÓÐùò/ %Ks   ÇM7r.   Nr�   )rš   r^   rW   r<   )r0   r1   r2   r3   r4   rY   r‚   r•   r”   rÁ   r5   r.   r+   r*   r   r   Â   sd   ‡ ñð 'Ó&Ø*ØÓØ6Ø&Ó&ØFØ8Ó8ØGàó!ó ð!ð óPó ðPð (,÷ ; ò ; r+   r   c                ó6   • U R                   R                  5       $ )z*Get the JSON schema for a variable's type.)Útype_adapterÚjson_schema)Úvariables    r*   Ú_get_json_schemarÇ   '  s   € à× Ñ ×,Ñ,Ó.Ð.r+   c                ó¦   • SSK Jn  U" U R                  5      (       a  gU R                  R	                  U R                  5      R                  S5      $ )z�Get the serialized default value for a variable.

Returns None if the default is a ResolveFunction (can't serialize a function).
r   )Úis_resolve_functionNzutf-8)Úlogfire.variables.variablerÉ   ÚdefaultrÄ   Ú	dump_jsonÚdecode)rÆ   rÉ   s     r*   Ú_get_default_serializedrÎ   ,  sC   € õ
 ?á˜8×+Ñ+×,Ñ,Øà× Ñ ×*Ñ*¨8×+;Ñ+;Ó<×CÑCÀGÓLÐLr+   c           	     ó¬   • SSK Jn   U R                  R                  U5        [	        UUSS9$ ! U a  n[	        UUS[        U5      S9s SnA$ SnAff = f)z@Check if a label's value is compatible with the variable's type.r   ©ÚValidationErrorT)rA   r]   r_   F©rA   r]   r_   r`   N)ÚpydanticrÑ   rÄ   Úvalidate_jsonr[   r<   )rÆ   rA   r]   rÑ   rº   s        r*   Ú_check_label_compatibilityrÕ   9  sf   € õ )ð
Ø×Ñ×+Ñ+Ð,<Ô=Ü!ØØ-Øñ
ð 	
øð
 ó 
Ü!ØØ-ØÜ�a“&ñ	
õ 	
ûð
ús   ˆ%. ®A´AÁAÁAc                ó–  • SSK Jn  / nUR                  R                  5        HR  u  pE[	        XR5      (       d  M  [        U UUR                  5      nUR                  (       a  MA  UR                  U5        MT     UR                  bC  [        U SUR                  R                  5      nUR                  (       d  UR                  U5        U$ )z–Check all labeled values and latest_version against the variable's Python type.

Returns a list of incompatible labels (empty if all are compatible).
r   ©ÚLabeledValueÚlatest)
Úlogfire.variables.configrØ   ÚlabelsÚitemsÚ
isinstancerÕ   r]   r_   r¯   Úlatest_version)rÆ   Ú
server_varrØ   ÚincompatiblerA   Úlabeled_valueÚcompats          r*   Ú_check_all_label_compatibilityrã   Q  s´   € õ 6à-/€LØ *× 1Ñ 1× 7Ñ 7Ö 9ÑˆÜ�m×2Ó2Ü/ØØØ×.Ñ.óˆFð
 ×'×'Ñ'Ø×#Ñ# FÖ+ñ !:ð × Ñ Ñ,Ü+ØØØ×%Ñ%×6Ñ6ó
ˆð
 ×#×#Ø×Ñ Ô'ØÐr+   c                óJ  • SSK Jn  SSKJn  / nUR                  R                  5        H3  u  pV[        Xc5      (       d  M   U R                  UR                  5        M5     UR                  b(   U R                  UR                  R                  5        U$ U$ ! U a9  nUR                  [        UUR                  S[        U5      S95         SnAM¨  SnAff = f! U aC  nUR                  [        SUR                  R                  S[        U5      S95         SnAU$ SnAff = f)a  Check all labeled values and latest_version against a TypeAdapter.

Similar to _check_all_label_compatibility but works with a TypeAdapter
instead of a Variable instance, for use with push_variable_types.

Returns a list of incompatible labels (empty if all are compatible).
r   rÐ   r×   FrÒ   NrÙ   )rÓ   rÑ   rÚ   rØ   rÛ   rÜ   rÝ   rÔ   r]   r¯   r[   r<   rÞ   )Úadapterrß   rÑ   rØ   rà   rA   rá   rº   s           r*   Ú_check_type_label_compatibilityræ   q  s  € õ )å5à-/€LØ *× 1Ñ 1× 7Ñ 7Ö 9ÑˆÜ�m×2Ó2ð
Ø×%Ñ% m×&DÑ&DÖEñ !:ð × Ñ Ñ,ð
	Ø×!Ñ! *×";Ñ";×"LÑ"LÔMð Ðˆ<Ðøð- #ó Ø×#Ñ#Ü&Ø#Ø)6×)GÑ)GØ&+Ü! !›fñ	÷ò ûðûð ó 	Ø×ÑÜ"Ø"Ø%/×%>Ñ%>×%OÑ%OØ"'Ü˜a›&ñ	÷ð ð Ðûð	ús0   ÁBÁ.%C ÂCÂ.CÃCÃD"Ã8DÄD"c                óš  • / nU  Vs1 s H  o3R                   iM     nnU  GHb  n[        U5      nUR                  nUR                  R	                  UR                   5      nUc3  [        U5      n	UR                  [        UR                   SUU	US95        Mv  UR                  n
UR                  n[        R                  " USS9nU
(       a  [        R                  " U
SS9OSnXÍ:g  nU=(       d    SnU=(       d    SnUU:g  nU(       a@  [        XX5      nUR                  [        UR                   SUU
U(       a  UOSUUUS95        GM'  [        XX5      nUR                  [        UR                   S	U(       a  UOSUUUS
95        GMe     UR                  R                  5        Vs/ s H  nUU;  d  M  UPM     nn[        UUS9$ s  snf s  snf )a  Compute the diff between local variables and server config.

Args:
    variables: Local variable definitions.
    server_config: Server variable configurations (from provider.get_all_variables_config()).

Returns:
    A VariableDiff describing the changes needed.
NÚcreate)r=   rd   re   rg   rj   T)Ú	sort_keysz{}Úupdate_schema)r=   rd   re   rf   rh   rj   rk   rl   rv   )r=   rd   rh   rj   rk   rl   )rp   rr   )r=   rÇ   ÚdescriptionÚ	variablesÚgetrÎ   r¯   rb   rÅ   ÚjsonÚdumpsrã   Úkeysrn   )rì   Úserver_configrp   ÚvÚlocal_namesrÆ   re   rj   rß   Údefault_serializedrf   rk   Úlocal_normalizedÚserver_normalizedÚschema_changedÚlocal_desc_normalizedÚserver_desc_normalizedrl   rà   r=   Úorphaneds                        r*   Ú_compute_diffrû   ž  sÄ  € ð %'€GÙ#,Ó-¢9˜a—6”6¡9€KÐ-äˆÜ'¨Ó1ˆØ$×0Ñ0ÐØ"×,Ñ,×0Ñ0°·±Ó?ˆ
àÑä!8¸Ó!BÐØ�N‰NÜØ!Ÿ™Ø (Ø!-Ø"4Ø&7ñöð '×2Ñ2ˆMØ!+×!7Ñ!7Ðô  $Ÿzšz¨,À$ÑGÐÞMZ¤§
¢
¨=ÀDÒ IÐ`dÐà-ÑBˆNð %6×$=¸Ð!Ø%7×%?¸4Ð"Ø"7Ð;QÑ"QÐæä=¸hÓS�à—‘Ü"Ø%Ÿ]™]Ø$3Ø%1Ø&3Þ<H©LÈdØ*;Ø+=Ø,?ñ	÷ô  >¸hÓS�à—‘Ü"Ø%Ÿ]™]Ø$/Þ<H©LÈdØ*;Ø+=Ø,?ñ÷	ñm ðD "/×!8Ñ!8×!=Ñ!=Ô!?Ó[Ò!?˜À4È{ÑCZ—Ñ!?€HÐ[ä À8ÑLÐLùòM .ùòH \s   ‡GÆ#
GÆ1Gc                óÌ	  • / nU R                    Vs/ s H  o"R                  S:X  d  M  UPM     nnU R                    Vs/ s H  o"R                  S:X  d  M  UPM     nnU R                    Vs/ s H  o"R                  S:X  d  M  UPM     nnU R                    Vs/ s H  o"R                  (       d  M  UPM     nnU(       aÄ  UR                  S[         S[
         35        U HŸ  nUR                  S[         SUR                   [
         35        UR                  (       a  UR                  SUR                   35        UR                  (       a   UR                  S	UR                   35        MŽ  UR                  S
5        M¡     U(       aÃ  UR                  S[         S[
         35        U Hž  nUR                  S[         SUR                   [
         35        UR                  (       d  MA  UR                  S[         S[
         35        UR                   H.  nUR                  SUR                   SUR                   35        M0     M      U(       a_  UR                  S[         S[        U5       S[
         35        U H.  nUR                  S[         SUR                   [
         35        M0     U Vs/ s H  o"R                  (       d  M  UPM     n	nU	(       a°  UR                  S[         S[
         35        U	 H‹  nUR                  S[         SUR                   [
         35        UR                  S[         S[
         35        UR                   H.  nUR                  SUR                   SUR                   35        M0     M�     U R                   (       aS  UR                  S[         S[
         35        U R                    H$  n
UR                  S[         SU
 [
         35        M&     U(       aÃ  UR                  S["         S[
         35        UR                  ["         S[
         35        U H€  nUR                  S["         SUR                   [
         35        UR                  =(       d    SnUR$                  =(       d    SnUR                  SU 35        UR                  SU 35        M‚     SR'                  U5      $ s  snf s  snf s  snf s  snf s  snf )z(Format the diff for display to the user.rè   rê   rv   r�   ú=== Variables to CREATE ===rž   ú+ ú    Description: z    Example value: z.    (No example value - default is a function)z,=== Variables to UPDATE (schema changed) ===ú~ ú    z#Warning: Incompatible label values:z      - rŸ   ú=== No changes needed (r£   z.=== Validation warnings (schema unchanged) ===u   âš  zIncompatible label values:z1=== Server-only variables (not in local code) ===r¢   r¤   r¥   r¦   r§   r¨   r©   )rp   rd   rl   r¯   r¬   rª   r=   rj   rg   r­   rh   r«   rA   r`   Ú	ANSI_GRAYr˜   rr   r®   rk   r±   )r½   r·   rz   ÚcreatesÚupdatesÚ	unchangedÚdescription_diffsÚchangerâ   Úunchanged_with_incompatibler=   r¾   r¿   s                r*   Ú_format_diffr
  õ  sû  € à€EàŸ,š,ÓDš,�Q¯-©-¸8Ñ*C�q™,€GÐDØŸ,š,ÓKš,�Q¯-©-¸?Ñ*J�q™,€GÐKØ ŸLšLÓIšL�q¯M©M¸[Ñ,H—™L€IÐIØ$(§L¢LÓJ¢L˜q×4IÕ4IŸ¡LÐÐJæØ�‰�rœ*˜Ð%@ÄÀÐMÔNÛˆFØ�L‰L˜2œj˜\¨¨F¯K©K¨=¼¸ÐEÔFØ×'×'Ø—‘Ð0°×1IÑ1IÐ0JÐKÔLØ×#×#Ø—‘Ð2°6×3GÑ3GÐ2HÐIÖJà—‘ÐMÖNñ ö Ø�‰�rœ+˜Ð&RÔS]ÐR^Ð_Ô`ÛˆFØ�L‰L˜2œk˜]¨"¨V¯[©[¨M¼*¸ÐFÔGØ×)×)Ñ)Ø—‘˜t¤H :Ð-PÔQ[ÐP\Ð]Ô^Ø$×8Ô8�FØ—L‘L 8¨F¯L©L¨>¸¸F¿L¹L¸>Ð!JÖKó 9ñ	 ö Ø�‰�rœ)˜Ð$;¼CÀ	»NÐ;KÈ?Ô[eÐZfÐgÔhÛˆFØ�L‰L˜2œi˜[¨¨6¯;©;¨-¼
°|ÐDÖEñ  ñ /8Ó"Qªi¨×;PÕ;P§1©iÐÐ"QÞ"Ø�‰�rœ+˜Ð&TÔU_ÐT`ÐaÔbÛ1ˆFØ�L‰L˜2œk˜]¨'°&·+±+°¼z¸lÐKÔLØ�L‰L˜4¤˜zÐ)CÄJÀ<ÐPÔQØ ×4Ô4�Ø—‘˜x¨¯© ~°R¸¿¹°~ÐFÖGó 5ñ 2ð ×%×%Ø�‰�rœ)˜Ð$UÔV`ÐUaÐbÔcØ×2Ô2ˆDØ�L‰L˜2œi˜[¨¨4¨&´°Ð=Ö>ñ 3ö Ø�‰�rœ)˜Ð$SÔT^ÐS_Ð`ÔaØ�‰œ	�{Ð"jÔkuÐjvÐwÔxÛ'ˆFØ�L‰L˜2œi˜[¨¨6¯;©;¨-¼
°|ÐDÔEØ×1Ñ1×=°XˆJØ ×3Ñ3×?°xˆKØ�L‰L˜<¨
 |Ð4Ô5Ø�L‰L˜<¨ }Ð5Ö6ñ (ð �9‰9�UÓÐùòq EùÚKùÚIùÚJùò8 #Rs9   ‘S¨S¾SÁSÁ+SÂSÂSÂ0SÊ7S!ËS!r   c                ó    • UR                    H>  nUR                  S:X  a  [        X5        M   UR                  S:X  d  M2  [        XU5        M@     g)z%Apply the changes using the provider.rè   rê   N)rp   rd   Ú_create_variableÚ_update_variable_schema)Úproviderr½   rñ   r  s       r*   Ú_apply_changesr  4  s@   € ð —,”,ˆØ×Ñ Ó)Ü˜XÖ.Ø×Ñ ?Õ2Ü# H°mÖDò	 r+   c           
     óð   • SSK JnJn  U" UR                  UR                  0 U" 0 S9/ UR
                  UR                  S9nU R                  U5        [        S[         SUR                   [         35        g)z'Create a new variable via the provider.r   )ÚRolloutr   )rÛ   )r=   rë   rÛ   ÚrolloutÚ	overridesrÅ   Úexamplerž   z	Created: N)rÚ   r  r   r=   rj   re   rg   Úcreate_variableÚprintr¬   rª   )r  r  r  r   Úconfigs        r*   r  r  A  sq   € ÷
 Añ Ø�[‰[Ø×,Ñ,ØÙ˜rÑ"ØØ×'Ñ'Ø×$Ñ$ñ€Fð ×Ñ˜VÔ$Ü	ˆBŒzˆl˜) F§K¡K =´°Ð
=Õ>r+   c           	     ó¼  • SSK Jn  UR                  R                  UR                  5      nUc&  [        S[         SUR                   [         35        gU" UR                  UR                  UR                  UR                  UR                  UR                  S9nU R                  UR                  U5        [        S[         SUR                   [         35        g)z6Update an existing variable's schema via the provider.r   )r   Nrž   z,Warning: Could not find existing config for )r=   rë   rÛ   r  r  rÅ   zUpdated schema: )rÚ   r   rì   rí   r=   r  r«   rª   rë   rÛ   r  r  re   Úupdate_variabler­   )r  r  rñ   r   Úexistingr  s         r*   r  r  X  s¾   € õ 8ð ×&Ñ&×*Ñ*¨6¯;©;Ó7€HØÑä�”8�*ÐHÈÏÉÈÔV`ÐUaÐbÔcØñ Ø�]‰]Ø×(Ñ(Ø�‰Ø× Ñ Ø×$Ñ$Ø×'Ñ'ñ€Fð ×Ñ˜VŸ[™[¨&Ô1Ü	ˆBŒ{ˆmÐ+¨F¯K©K¨=¼¸Ð
EÕFr+   c                  ól  • \ rS rSrSr\  S       SS jj5       r      SS jrSS S jjrS!S"S jjr	S#S	 jr
S$S
 jrS%S jrS&S jrS'S jrS(S jrS)S jrSSSS.         S*S jjrS%S jrSSSS.         S+S jjr    S,S jrS-S jrS.S jrS/S jrSSSS.         S0S jjrSrg)1r   iu  z1Abstract base class for variable value providers.Nc                ó   • [         e)ab  Retrieve the serialized value for a variable.

Args:
    variable_name: The name of the variable to resolve.
    targeting_key: Optional key for deterministic label selection (e.g., user ID).
    attributes: Optional attributes for condition-based targeting rules.

Returns:
    A ResolvedVariable containing the serialized value (or None if not found).
)ÚNotImplementedError©rH   r†   Útargeting_keyÚ
attributess       r*   Úget_serialized_valueÚ%VariableProvider.get_serialized_valuex  s
   € ô" "Ð!r+   c                óÒ   • U R                  U5      nUc  [        USSS9$ UR                  R                  U5      nUc  [        USSS9$ UR	                  U5      u  pV[        UUUUSS9$ )a   Retrieve the serialized value for a specific label of a variable.

This method bypasses rollout weights and targeting, directly selecting the
specified label. Used for explicit label selection.

Args:
    variable_name: The name of the variable to resolve.
    label: The name of the label to select.

Returns:
    A ResolvedVariable containing the serialized value (or None if not found).

Note:
    The default implementation uses get_variable_config to look up the label.
    Subclasses may override this for more efficient implementations.
NÚunrecognized_variable©r=   r>   r?   Úresolved)r=   r>   rA   rB   r?   )Úget_variable_configr   rÛ   rí   Ú
follow_ref)rH   r†   rA   r  rá   Ú
serializedrB   s          r*   Úget_serialized_value_for_labelÚ/VariableProvider.get_serialized_value_for_label‹  s�   € ð* ×)Ñ)¨-Ó8ˆØ‰>Ü#¨¸dÐLcÑdÐdàŸ™×)Ñ)¨%Ó0ˆØÑ Ü#¨¸dÈJÑWÐWà$×/Ñ/°Ó>Ñˆ
ÜØØØØØñ
ð 	
r+   Fc                ó   • g)añ  Refresh the value provider.

Only relevant to remote providers where initial retrieval may be asynchronous.
Calling this method is intended to block until an initial retrieval happens, but is not guaranteed
to eagerly retrieve any updates if the provider implements some kind of caching; the `force` argument
is provided as a way to ignore any caching.

Args:
    force: Whether to force refresh. If using a provider with caching, setting this to `True` triggers a refresh
    ignoring the cache.
Nr.   )rH   Úforces     r*   ÚrefreshÚVariableProvider.refresh±  s   € ð 	r+   c                ó   • g)z„Clean up any resources used by the provider.

Args:
    timeout_millis: The timeout budget in milliseconds for shutdown operations.
Nr.   )rH   Útimeout_milliss     r*   ÚshutdownÚVariableProvider.shutdown¿  s   € ð 	r+   c                ó   • g)a¬  Start any background tasks for this provider.

This is called after the provider is created and the Logfire instance is available.
Providers that need to run background tasks (like polling) should override this method
to start those tasks, using the provided logfire instance for error logging.

Args:
    logfire_instance: The Logfire instance to use for error logging, or None if
        variable instrumentation is disabled.
Nr.   )rH   Úlogfire_instances     r*   ÚstartÚVariableProvider.startÇ  s   € ð 	r+   c                ó   • g)a/  Retrieve the full configuration for a variable.

Args:
    name: The name of the variable.

Returns:
    The VariableConfig if found, or None if the variable doesn't exist.

Note:
    Subclasses should override this method to provide actual implementations.
    The default implementation returns None.
Nr.   ©rH   r=   s     r*   r'  Ú$VariableProvider.get_variable_configÔ  s   € ð r+   c                ó   • SSK Jn  U" 0 S9$ )zäRetrieve all variable configurations.

This is used by push_variables() to compute diffs.

Returns:
    A VariablesConfig containing all variable configurations.
    Returns an empty VariablesConfig if no configs are available.
r   )r   )rì   )rÚ   r   )rH   r   s     r*   Úget_all_variables_configÚ)VariableProvider.get_all_variables_configã  s   € õ 	=á¨Ñ,Ð,r+   c                ó\   • [         R                  " [        U 5      R                   S3SS9  U$ )a†  Create a new variable configuration.

Args:
    config: The configuration for the new variable.

Returns:
    The created VariableConfig.

Raises:
    VariableAlreadyExistsError: If a variable with this name already exists.

Note:
    Subclasses should override this method to provide actual implementations.
    The default implementation emits a warning and returns the config unchanged.
ú! does not persist variable writesé   ©Ú
stacklevel©ÚwarningsÚwarnÚtyper0   ©rH   r  s     r*   r  Ú VariableProvider.create_variableð  s0   € ô  	�ŠÜ�D‹z×"Ñ"Ð#Ð#DÐEØò	
ð ˆr+   c                ó\   • [         R                  " [        U 5      R                   S3SS9  U$ )a¨  Update an existing variable configuration.

Args:
    name: The name of the variable to update.
    config: The new configuration for the variable.

Returns:
    The updated VariableConfig.

Raises:
    VariableNotFoundError: If the variable does not exist.

Note:
    Subclasses should override this method to provide actual implementations.
    The default implementation emits a warning and returns the config unchanged.
r?  r@  rA  rC  )rH   r=   r  s      r*   r  Ú VariableProvider.update_variable  s0   € ô" 	�ŠÜ�D‹z×"Ñ"Ð#Ð#DÐEØò	
ð ˆr+   c                óZ   • [         R                  " [        U 5      R                   S3SS9  g)a  Delete a variable configuration.

Args:
    name: The name of the variable to delete.

Raises:
    VariableNotFoundError: If the variable does not exist.

Note:
    Subclasses should override this method to provide actual implementations.
    The default implementation emits a warning.
r?  r@  rA  NrC  r9  s     r*   Údelete_variableÚ VariableProvider.delete_variable  s)   € ô 	�ŠÜ�D‹z×"Ñ"Ð#Ð#DÐEØó	
r+   c                óÎ   • UR                  5        HQ  u  p#Uc  U R                  U5        M  U R                  U5      c  U R                  U5        M@  U R	                  X#5        MS     g)a¹  Update multiple variables atomically.

This default implementation processes updates sequentially. Subclasses
(especially remote providers) may override this to batch operations
into a single API call for better performance.

Args:
    updates: A mapping of variable names to their new configurations.
        Unrecognized names will be created.
        A None value means the variable should be deleted.
        All others will be updated.
N)rÜ   rL  r'  r  r  )rH   r  r=   r  s       r*   Úbatch_updateÚVariableProvider.batch_update/  sV   € ð $ŸM™MžO‰LˆDØ‰~Ø×$Ñ$ TÖ*Ø×)Ñ)¨$Ó/Ñ7Ø×$Ñ$ VÖ,à×$Ñ$ TÖ2ò ,r+   r   )ÚmodeÚdry_runÚyesc               óŠ	  • UR                   (       d  [        S5        g U R                  SS9   U R                  5       n/ n/ n/ n	/ n
UR                   R                  5        H|  u  p¼UR                   R                  U5      nUc  UR                  U5        M6  UR                  S1S	9UR                  S1S	9:w  a  UR                  U5        Mk  U
R                  U5        M~     US
:X  a5  UR                    H%  nX±R                   ;  d  M  U	R                  U5        M'     / nU(       aÕ  UR                  S[         S[
         35        U H°  nUR                  S[         SU [
         35        UR                   U   nUR                  (       a  UR                  SUR                   35        UR                  (       d  Mu  UR                  SSR                  UR                  R!                  5       5       35        M²     U(       aI  UR                  S[         S[
         35        U H$  nUR                  S[         SU [
         35        M&     U	(       aI  UR                  S[         S[
         35        U	 H$  nUR                  S[         SU [
         35        M&     U
(       aU  UR                  S["         S[%        U
5       S[
         35        U
 H$  nUR                  S["         SU [
         35        M&     [        SR                  U5      5        ['        U=(       d    U=(       d    U	5      nU(       d  [        S[         S[
         35        gU(       a  [        S[         S[
         35        gU(       d6  [        5          [)        S5      nUR/                  5       S;  a  [        S5        g[        S5         0 nXx-    H  nUR                   U   UU'   M     U	 H  nSUU'   M
     U R1                  U5        [        S[         S [
         35        g! [         a%  n[        [         SU [
         35         SnAGNSnAff = f! [         a$  n[        [         SU [
         35         SnAgSnAff = f! [*        [,        4 a    [        S5         gf = f! [         a$  n[        [         SU [
         35         SnAgSnAff = f)!aâ  Push a VariablesConfig to this provider.

This method pushes a complete VariablesConfig (including labels and rollouts)
to the provider. It's useful for:
- Pushing configs generated or modified locally
- Pushing configs read from files
- Partial updates (merge mode) or full replacement (replace mode)

Args:
    config: The VariablesConfig to push.
    mode: 'merge' updates/creates only variables in config (leaves others unchanged).
          'replace' makes the server match the config exactly (deletes missing variables).
    dry_run: If True, only show what would change without applying.
    yes: If True, skip confirmation prompt.

Returns:
    True if changes were applied (or would be applied in dry_run mode), False otherwise.
zNo variables in config to push.FT©r-  ú%Warning: Could not refresh provider: NúError fetching current config: rÞ   )Úexcluder   r�   rý   rž   rþ   rÿ   z    Labels: z, z=== Variables to UPDATE ===r   z=== Variables to DELETE ===z- r  r£   ú*No changes needed. Provider is up to date.ú"Dry run mode - no changes applied.úApply these changes? [y/N] ú	
Aborted.©ÚyrS  úAborted.ú
Applying changes...úError applying changes: z$Done! Variables pushed successfully.)rì   r  r.  r‡   r­   rª   r<  r«   rÜ   rí   r¯   Ú
model_dumpr¬   rë   rÛ   r±   rð   r  r˜   r^   ÚinputÚEOFErrorÚKeyboardInterruptÚlowerrO  )rH   r  rQ  rR  rS  rº   rñ   r  r  Údeletesr  r=   Ú
var_configrß   r·   r   Úresponse_inputÚbatchs                     r*   Úpush_configÚVariableProvider.push_configD  s]  € ð4 ××ÜÐ3Ô4Øð	XØ�L‰L˜tˆLÑ$ð
	Ø ×9Ñ9Ó;ˆMð  ˆØˆØˆØ!ˆ	à &× 0Ñ 0× 6Ñ 6Ö 8ÑˆDØ&×0Ñ0×4Ñ4°TÓ:ˆJØÑ!Ø—‘˜tÖ$Ø×&Ñ&Ð0@Ð/AÐ&ÐBÀj×F[ÑF[ÐeuÐdvÐF[ÐFwÓwØ—‘˜tÖ$à× Ñ  Ö&ñ !9ð �9ÓØ%×/Ô/�Ø×/Ñ/Õ/Ø—N‘N 4Ö(ñ 0ð
 ˆæØ�L‰L˜2œj˜\Ð)DÄZÀLÐQÔRÛ�Ø—‘˜r¤* ¨R°¨v´j°\ÐBÔCØ#×-Ñ-¨dÑ3�
Ø×)×)Ø—L‘LÐ#4°Z×5KÑ5KÐ4LÐ!MÔNØ×$×$Ñ$Ø—L‘L <°·	±	¸*×:KÑ:K×:PÑ:PÓ:RÓ0SÐ/TÐ!UÖVñ  ö Ø�L‰L˜2œk˜]Ð*EÄjÀ\ÐRÔSÛ�Ø—‘˜r¤+ ¨b°°´z°lÐCÖDñ  ö Ø�L‰L˜2œh˜ZÐ'BÄ:À,ÐOÔPÛ�Ø—‘˜r¤( ¨2¨d¨V´J°<Ð@ÖAñ  ö Ø�L‰L˜2œi˜[Ð(?ÄÀIÃÐ?OÈÔ_iÐ^jÐkÔlÛ!�Ø—‘˜r¤) ¨B¨t¨f´Z°LÐAÖBñ "ô 	ˆd�i‰i˜ÓÔä˜7×8 g×8°Ó9ˆÞÜ�B”z�lÐ"LÌZÈLÐYÔZØæÜ�B”{�mÐ#EÄjÀ\ÐRÔSØö ÜŒGðÜ!&Ð'DÓ!E�ð
 ×#Ñ#Ó%¨\Ó9Ü�jÔ!Øô 	Ð%Ô&ð	à68ˆEØÔ)�Ø$×.Ñ.¨tÑ4��d“ñ *ã�Ø"��d“ñ  ð ×Ñ˜eÔ$ô
 	�”:�,ÐBÄ:À,ÐOÔPØøôG ó 	XÜ”[�MÐ!FÀqÀcÌ*ÈÐV×WÒWûð	Xûô ó 	Ü”X�JÐ=¸a¸SÄÀÐMÔNÜûð	ûôJ Ô/Ð0ó Ü�lÔ#Ùðûô& ó 	Ü”X�JÐ6°q°c¼*¸ÐFÔGÜûð	úsX   ŸP ¯Q ÎQ3 Î8>R Ð
P?ÐP:Ð:P?Ñ
Q0ÑQ+Ñ+Q0Ñ3RÒRÒ
SÒR=Ò=Sc                ó@   • U R                  SS9  U R                  5       $ )a  Pull the current variable configuration from the provider.

This method fetches the complete configuration from the provider,
useful for generating local copies of the config that can be modified.

Returns:
    The current VariablesConfig from the provider.
TrU  )r.  r<  rG   s    r*   Úpull_configÚVariableProvider.pull_configÊ  s!   € ð 	�‰˜4ˆÑ Ø×,Ñ,Ó.Ð.r+   ©rR  rS  Ústrictc               óü  • U(       d  [        S5        g U R                  SS9   U R                  5       n[        X5      n[        [        U5      5        UR                   Vs/ s H  oˆR                  (       d  M  UPM     n	nU	(       a€  [        S U	 5       5      n
[        S	 U	 5       5      nU
(       a
  U(       a  S
nOU
(       a  SnOSnU(       a  [        S[         SU S[         35        g[        S[         SU [         35        UR                  (       d  [        S[         S[         35        gU(       a  [        S[         S[         35        gU(       d6  [        5          [        S5      nUR#                  5       S;  a  [        S5        g[        S5         [%        XU5        [        S[         S[         35        g! [         a%  n[        [         SU [         35         SnAGNÊSnAff = f! [         a$  n[        [         SU [         35         SnAgSnAff = fs  snf ! [        [         4 a    [        S5         gf = f! [         a$  n[        [         SU [         35         SnAgSnAff = f)a¡  Push variable definitions to this provider.

This method syncs local variable definitions (metadata only) with the provider:
- Creates new variables that don't exist in the provider
- Updates JSON schemas for existing variables if they've changed
- Warns about existing label values that are incompatible with new schemas

Args:
    variables: Variable instances to push.
    dry_run: If True, only show what would change without applying.
    yes: If True, skip confirmation prompt.
    strict: If True, fail if any existing label values are incompatible with new schemas.

Returns:
    True if changes were applied (or would be applied in dry_run mode), False otherwise.
zANo variables to push. Create variables using logfire.var() first.FTrU  rV  NrW  c              3  ó>   #   • U  H  oR                   S :H  v •  M     g7f)rê   Nrw   rx   s     r*   r{   Ú2VariableProvider.push_variables.<locals>.<genexpr>  s   é € Ð)iÒThÈq¯-©-¸?Ö*JÒThùr}   c              3  ó>   #   • U  H  oR                   S :H  v •  M     g7fru   rw   rx   s     r*   r{   rt  	  s   é € Ð,hÒSgÈa¯]©]¸kÖ-IÒSgùr}   z†Some existing label values are incompatible with the variable types, and some schema changes will make additional values incompatible.zQSome schema changes will result in label values incompatible with the new schema.zWSome existing label values are incompatible with the variable types (schema unchanged).r�   úError: ú$
Set strict=False to proceed anyway.ú	Warning: rY  rZ  r[  r\  r]  r_  r`  ra  z$Done! Variables synced successfully.)r  r.  r‡   r­   rª   r<  r«   rû   r
  rp   rh   r~   r   r¬   rc  rd  re  rf  r  )rH   rì   rR  rS  rq  rº   rñ   r½   rz   Úincompatible_changesÚhas_schema_incompatibleÚhas_unchanged_incompatibleÚmessageri  s                 r*   Úpush_variablesÚVariableProvider.push_variablesÖ  sO  € ö0 ÜÐUÔVØð	XØ�L‰L˜tˆLÑ$ð
	Ø ×9Ñ9Ó;ˆMô ˜YÓ6ˆô 	Œl˜4Ó Ô!ð ,0¯<ª<ÓQª< a×;PÕ;P§©<ÐÐQÞÜ&)Ñ)iÑThÓ)iÓ&iÐ#Ü),Ñ,hÑSgÓ,hÓ)hÐ&Þ&Ö+Eð c‘Þ(Øm‘às�ÞÜ˜œ8˜* G¨G¨9Ð4YÔZdÐYeÐfÔgØä˜œ;˜- y°°	¼*¸ÐFÔGà××Ü�B”z�lÐ"LÌZÈLÐYÔZØæÜ�B”{�mÐ#EÄjÀ\ÐRÔSØö ÜŒGðÜ!&Ð'DÓ!E�ð
 ×#Ñ#Ó%¨\Ó9Ü�jÔ!Øô 	Ð%Ô&ð	Ü˜4 }Ô5ô
 	�”:�,ÐBÄ:À,ÐOÔPØøô ó 	XÜ”[�MÐ!FÀqÀcÌ*ÈÐV×WÒWûð	Xûô ó 	Ü”X�JÐ=¸a¸SÄÀÐMÔNÜûð	üò  Røô: Ô/Ð0ó Ü�lÔ#Ùðûô ó 	Ü”X�JÐ6°q°c¼*¸ÐFÔGÜûð	úsd   •G ¥G6 Á"H'Á:H'Å'H, ÆI Ç
G3ÇG.Ç.G3Ç6
H$È HÈH$È,I
É	I
É
I;ÉI6É6I;c           
     óh  • U(       d  [        / S/ / S9$ U R                  SS9  U R                  5       nU Vs/ s H*  o3R                  UR                  ;  d  M  UR                  PM,     nnU Vs/ s H   o3R                  UR                  ;   d  M  UPM"     nnUR                  U5      n/ nUR                  5        H8  u  p‰U	R                  5        H  u  p«UR                  [        UU
US95        M!     M:     / nU H—  nUR                  R                  UR                  5      nUc  M-  UR                  =(       d    SnUR                  =(       d    SnUU:w  d  M_  UR                  [        UR                  UR                  UR                  S95        M™     [        U[        U5      UUS9$ s  snf s  snf )a¤  Validate that provider-side variable label values match local type definitions.

This method fetches the current variable configuration from the provider and
validates that all label values can be deserialized to the expected types
defined in the local Variable instances.

Args:
    variables: Variable instances to validate.

Returns:
    A ValidationReport containing any errors found. Use `report.is_valid` to check
    if validation passed, and `report.format()` to get a human-readable summary.

Example:
    ```python skip="true"
    report = provider.validate_variables(variables)
    if not report.is_valid:
        print(report.format())
        sys.exit(1)
    ```
r   ©rŽ   r�   r‘   r’   TrU  )r†   rA   r`   N)r†   rj   rk   )r   r.  r<  r=   rì   Úget_validation_errorsrÜ   r¯   r„   rí   rë   rŠ   r˜   )rH   rì   rñ   rò   r‘   Úvariables_on_serverÚ
error_dictrŽ   Úvar_nameÚlabel_errorsrA   r`   r’   rÆ   rß   r¾   r¿   s                    r*   Úvalidate_variablesÚ#VariableProvider.validate_variables6  s«  € ö2 Ü#ØØ"#Ø(*Ø(*ñ	ð ð 	�‰˜4ˆÑ ð ×5Ñ5Ó7ˆñ 4=Ó"f²9¨aÇÁÈm×NeÑNeÑ@e£6 1§6¤6±9ÐÐ"fñ +4ÓYª) Q·v±vÀ×AXÑAXÑ7XŸq©)ÐÐYð #×8Ñ8Ð9LÓMˆ
ð .0ˆØ&0×&6Ñ&6Ö&8Ñ"ˆHØ ,× 2Ñ 2Ö 4‘�Ø—‘Ü(Ø&.Ø#Ø#ñöó !5ñ '9ð @BÐÛ+ˆHØ&×0Ñ0×4Ñ4°X·]±]ÓCˆJØÓ%à%×1Ñ1×9°T�
Ø(×4Ñ4×<¸�Ø Õ,Ø+×2Ñ2Ü-Ø*2¯-©-Ø.6×.BÑ.BØ/9×/EÑ/Eñöñ ,ô  ØÜ! )›nØ$;Ø$;ñ	
ð 	
ùòK #gùò Zs   ·F*ÁF*Á.F/ÂF/c                ó\   • [         R                  " [        U 5      R                   S3SS9  0 $ )zrList all variable types from the provider.

Returns:
    A dictionary mapping type names to their configurations.
z  does not support variable typesr@  rA  rC  rG   s    r*   Úlist_variable_typesÚ$VariableProvider.list_variable_typesŒ  s0   € ô 	�ŠÜ�D‹z×"Ñ"Ð#Ð#CÐDØò	
ð ˆ	r+   c                ó@   • U R                  5       R                  U5      $ )z�Get a variable type by name.

Args:
    name: The name of the type to retrieve.

Returns:
    The VariableTypeConfig if found, None otherwise.
)r‰  rí   r9  s     r*   Úget_variable_typeÚ"VariableProvider.get_variable_type˜  s   € ð ×'Ñ'Ó)×-Ñ-¨dÓ3Ð3r+   c                ó\   • [         R                  " [        U 5      R                   S3SS9  U$ )zòCreate or update a variable type.

If a type with the given name exists, it will be updated.
Otherwise, a new type will be created.

Args:
    config: The type configuration to upsert.

Returns:
    The created or updated VariableTypeConfig.
z& does not persist variable type writesr@  rA  rC  rG  s     r*   Úupsert_variable_typeÚ%VariableProvider.upsert_variable_type£  s0   € ô 	�ŠÜ�D‹z×"Ñ"Ð#Ð#IÐJØò	
ð ˆr+   c               ó  • SSK Jn  SSKJnJnJn  U(       d  [        S5        g U R                  SS9   U R                  5       n
/ n0 nU Hb  n[        U[        5      (       a  Uu  pïO
UnU" U5      nU" U5      nUR                  5       nU" U5      nUXÏ'   UR!                  U" UUUS95        Md     / n/ n/ nU H�  nU
R#                  UR$                  5      nUc  UR!                  UR$                  5        M>  UR                  UR                  :w  a  UR!                  UR$                  5        Mu  UR!                  UR$                  5        M’     [        S[&         S[         35        [        S5        U(       a<  [        S[(         S[+        U5       S[         35        U H  n[        SU 35        M     U(       a<  [        S[         S[+        U5       S[         35        U H  n[        SU 35        M     U(       a<  [        S[,         S[+        U5       S[         35        U H  n[        SU 35        M     0 nU(       aŸ   U R/                  5       nU Hˆ  nUU   nUR0                  R3                  5        Hb  nUR4                  U:w  a  M  [7        UU5      nU(       d  M*  UR9                  U/ 5      nU H   nUR!                  UR$                  U45        M"     Md     MŠ     U(       aÒ  [        S[         S[         35        UR;                  5        Hd  u  nn[        S[         SU [         35        U H=  u  n n[        S[         SU < SUR<                  < SUR>                   [         3	5        M?     Mf     Sn!U(       a  [        S[         SU! S [         35        g[        S[         S!U! [         35        U(       d!  U(       d  [        S[(         S"[         35        gU(       a  [        S[         S#[         35        gU(       d6  [        5          [A        S$5      n"U"RG                  5       S&;  a  [        S'5        g[        S(5         U H6  nUR$                  U;   d  UR$                  U;   d  M%  U RI                  U5        M8     [        S[(         S*[         35        g! [         a%  n	[        [         SU	 [         35         S	n	A	GN™S	n	A	ff = f! [         a$  n	[        [         S
U	 [         35         S	n	A	gS	n	A	ff = f! [         a%  n	[        [         SU	 [         35         S	n	A	GNNS	n	A	ff = f! [B        [D        4 a    [        S%5         gf = f! [         a$  n	[        [         S)U	 [         35         S	n	A	gS	n	A	ff = f)+a‘  Push variable type definitions to this provider.

This method syncs local type definitions with the provider:
- Creates new types that don't exist in the provider
- Updates JSON schemas for existing types if they've changed
- Warns about schema changes
- Checks if existing variable label values are compatible with the new schemas

Args:
    types: Types to push. Items can be:
        - A type (name defaults to __name__ or str(type))
        - A tuple of (type, name) for explicit naming
    dry_run: If True, only show what would change without applying.
    yes: If True, skip confirmation prompt.
    strict: If True, abort when existing label values are incompatible with
        the new type schema.

Returns:
    True if changes were applied (or would be applied in dry_run mode), False otherwise.

Example:
    ```python skip="true"
    from pydantic import BaseModel


    class FeatureConfig(BaseModel):
        enabled: bool
        max_items: int = 10


    # Push using __name__ as type name
    provider.push_variable_types([FeatureConfig])

    # Push with explicit name
    provider.push_variable_types([(FeatureConfig, 'my_feature_config')])
    ```
r   r   )r   Úget_default_type_nameÚget_source_hintzNo types to push.FTrU  rV  NzError fetching current types: )r=   rÅ   Úsource_hintr�   zVariable Types Push Summaryz(========================================zNew types (z):z  + zSchema updates (z  ~ zUnchanged (z  = z.Warning: Could not check label compatibility: z$=== Label compatibility warnings ===rž   zType: r  u   âš  Variable z, label rŸ   zESome existing label values are incompatible with the new type schema.rv  rw  rx  z(No changes needed. Types are up to date.rZ  r[  r\  r]  r_  r`  ra  z)Done! Variable types synced successfully.)%rÓ   r   rÚ   r   r’  r“  r  r.  r‡   r­   rª   r‰  r«   rÝ   ÚtuplerÅ   r¯   rí   r=   Ú	ANSI_BOLDr¬   r˜   ÚANSI_DIMr<  rì   ÚvaluesÚ	type_nameræ   Ú
setdefaultrÜ   rA   r`   rc  rd  re  rf  r�  )#rH   ÚtypesrR  rS  rq  r   r   r’  r“  rº   Úserver_typesÚtype_configsÚtype_adaptersÚitemÚtr=   rå   rÅ   r”  r  r  r  r  r  Úincompatible_varsrñ   r™  rh  rà   Ú
var_issuesrâ   Úissuesr„  r|  ri  s#                                      r*   Úpush_variable_typesÚ$VariableProvider.push_variable_typesµ  s<  € õZ 	)çgÑgæÜÐ%Ô&Øð	XØ�L‰L˜tˆLÑ$ð
	Ø×3Ñ3Ó5ˆLð 24ˆØ57ˆÛˆDÜ˜$¤×&Ñ&Ø‘��4à�Ù,¨QÓ/�á! !“nˆGØ!×-Ñ-Ó/ˆKÙ)¨!Ó,ˆKà")ˆMÑØ×ÑÙ"ØØ +Ø +ñöñ ð*  ˆØˆØ!ˆ	ã"ˆFØ#×'Ñ'¨¯©Ó4ˆHØÑØ—‘˜vŸ{™{Ö+Ø×%Ñ%¨×);Ñ);Ó;Ø—‘˜vŸ{™{Ö+à× Ñ  §¡Ö-ñ #ô 	�”9�+Ð8¼¸ÐEÔFÜˆhŒæÜ�B”z�l +¬c°'«l¨^¸2¼j¸\ÐJÔKÛ�Ü˜˜T˜F�mÖ$ñ  ö Ü�B”{�mÐ#3´C¸³L°>ÀÄJÀ<ÐPÔQÛ�Ü˜˜T˜F�mÖ$ñ  ö Ü�B”x�j ¬C°	«NÐ+;¸2¼j¸\ÐJÔKÛ!�Ü˜˜T˜F�mÖ$ñ "ð NPÐÞðeØ $× =Ñ =Ó ?�Û!(�IØ+¨IÑ6�Gà&3×&=Ñ&=×&DÑ&DÖ&F˜
Ø%×/Ñ/°9Ó<Ù$Ü'FÀwÐPZÓ'[˜ß'˜<Ø):×)EÑ)EÀiÐQSÓ)T˜JÛ*6 Ø *× 1Ñ 1°:·?±?ÀFÐ2KÖ Ló +7ó 'Gñ ")ö Ü�B”{�mÐ#GÌ
À|ÐTÔUØ%6×%<Ñ%<Ö%>Ñ!�	˜6Ü˜œ;˜- v¨i¨[¼¸ÐEÔFÛ(.Ñ$�H˜fÜØœx˜jÐ(8¸¹ÀHÈVÏ\É\ÑL\Ð\^Ð_e×_kÑ_kÐ^lÔmwÐlxÐyöó )/ñ &?ð ^ˆGÞÜ˜œ8˜* G¨G¨9Ð4YÔZdÐYeÐfÔgØä˜œ;˜- y°°	¼*¸ÐFÔGæžwÜ�B”z�lÐ"JÌ:È,ÐWÔXØæÜ�B”{�mÐ#EÄjÀ\ÐRÔSØö ÜŒGðÜ!&Ð'DÓ!E�ð
 ×#Ñ#Ó%¨\Ó9Ü�jÔ!Øô 	Ð%Ô&ð	Û&�Ø—;‘; 'Ó)¨V¯[©[¸GÕ-CØ×-Ñ-¨fÖ5ñ 'ô 	�”:�,ÐGÌ
À|ÐTÔUØøôI ó 	XÜ”[�MÐ!FÀqÀcÌ*ÈÐV×WÒWûð	Xûô ó 	Ü”X�JÐ<¸Q¸CÄ
¸|ÐLÔMÜûð	ûôX ó eÜœ˜Ð%SÐTUÐSVÔWaÐVbÐc×dÒdûðeûô> Ô/Ð0ó Ü�lÔ#Ùðûô ó 	Ü”X�JÐ6°q°c¼*¸ÐFÔGÜûð	ús~   ¥R# µS ÉAT Ê"A T ÐT8 Ñ#U Ñ4U Ò#
SÒ-SÓSÓ
TÓS>Ó>TÔ
T5ÔT0Ô0T5Ô8UÕUÕ
VÕ#VÖVr.   ©NN©r†   r<   r  r@   r   zMapping[str, Any] | NonerW   úResolvedVariable[str | None])r†   r<   rA   r<   rW   r¨  )F)r-  r^   )iˆ  )r1  Úfloat)r5  zlogfire.Logfire | NonerW   rX   ©r=   r<   rW   zVariableConfig | None)rW   r   )r  r   rW   r   )r=   r<   r  r   rW   r   )r=   r<   rW   rX   )r  z dict[str, VariableConfig | None]rW   rX   )
r  r   rQ  r   rR  r^   rS  r^   rW   r^   )
rì   úSequence[Variable[object]]rR  r^   rS  r^   rq  r^   rW   r^   )rì   r«  rW   r   )rW   zdict[str, VariableTypeConfig])r=   r<   rW   zVariableTypeConfig | None)r  r   rW   r   )
r›  z+Sequence[type[Any] | tuple[type[Any], str]]rR  r^   rS  r^   rq  r^   rW   r^   )r0   r1   r2   r3   r4   r   r!  r*  r.  r2  r6  r'  r<  r  r  rL  rO  rk  rn  r}  r†  r‰  rŒ  r�  r¤  r5   r.   r+   r*   r   r   u  s�  † Ù;àð %)Ø/3ð	"àð"ð "ð"ð -ð	"ð
 
&ô"ó ð"ð$$
àð$
ð ð$
ð 
&ô	$
öLöôôô-ôô,ô.
ô$3ð2 !ØØñDàðDð ð	Dð
 ðDð ðDð 
õDôL
/ð  ØØñ^à-ð^ð ð	^ð
 ð^ð ð^ð 
õ^ð@R
à-ðR
ð 
ôR
ôl
ô	4ôð, ØØñ|à:ð|ð ð	|ð
 ð|ð ð|ð 
÷|ð |r+   c                  ó|   • \ rS rSrSr  S       SS jjrSS jrSSSS.         SS jjr    SS	 jrS
r	g)r   it  zRA variable provider that always returns None, used when no provider is configured.Nc                ó   • [        USSS9$ )aA  Return None for all variable lookups.

Args:
    variable_name: The name of the variable to resolve (ignored).
    targeting_key: Optional key for deterministic label selection (ignored).
    attributes: Optional attributes for condition-based targeting rules (ignored).

Returns:
    A ResolvedVariable with value=None.
NÚno_providerr%  )r   r  s       r*   r!  Ú)NoOpVariableProvider.get_serialized_valuex  s   € ô    ]¸$ÈÑVÐVr+   c                ó   • g)z–Return None for all variable lookups.

Args:
    name: The name of the variable (ignored).

Returns:
    Always None since no provider is configured.
Nr.   r9  s     r*   r'  Ú(NoOpVariableProvider.get_variable_configŠ  s   € ð r+   Frp  c               ó   • [        S5        g)z�No-op implementation that prints a message about missing provider configuration.

Returns:
    Always False since no provider is configured.
z]No variable provider configured. Configure a provider using logfire.configure(variables=...).F)r  )rH   rì   rR  rS  rq  s        r*   r}  Ú#NoOpVariableProvider.push_variables•  s   € ô 	ÐmÔnØr+   c                ó   • [        / S/ / S9$ )z•No-op implementation that returns an empty validation report.

Returns:
    An empty ValidationReport since there's no provider to validate against.
r   r€  )r   )rH   rì   s     r*   r†  Ú'NoOpVariableProvider.validate_variables¥  s   € ô  ØØØ$&Ø$&ñ	
ð 	
r+   r.   r¦  r§  rª  )
rì   úSequence[Variable[Any]]rR  r^   rS  r^   rq  r^   rW   r^   )rì   r¶  rW   r   )
r0   r1   r2   r3   r4   r!  r'  r}  r†  r5   r.   r+   r*   r   r   t  s™   † á\ð
 %)Ø/3ð	WàðWð "ðWð -ð	Wð
 
&õWô$	ð ØØñà*ðð ð	ð
 ðð ðð 
õð 
à*ð
ð 
÷
r+   r   )rÆ   úVariable[object]rW   zdict[str, Any])rÆ   r·  rW   r@   )rÆ   r·  rA   r<   r]   r<   rW   r[   )rÆ   r·  rß   r   rW   úlist[LabelCompatibility])rå   zTypeAdapter[Any]rß   r   rW   r¸  )rì   r«  rñ   r   rW   rn   )r½   rn   rW   r<   )r  r   r½   rn   rñ   r   rW   rX   )r  r   r  rb   rW   rX   )r  r   r  rb   rñ   r   rW   rX   )JÚ
__future__r   Ú_annotationsÚbuiltinsÚ@py_builtinsÚ_pytest.assertion.rewriteÚ	assertionÚrewriteÚ
@pytest_arrî   ÚsysrD  Úabcr   r   Úcollections.abcr   r   Ú
contextlibr   Údataclassesr	   Útypingr
   r   r   r   r   r   rÓ   r   rM   rÚ   r   r   r   rÊ   r   rª   r–  r—  r«   r¬   r­   r®   r  Ú__all__r   r    Úversion_infor'   r‡   r   r   r   r   r[   rb   rn   r„   rŠ   r   rÇ   rÎ   rÕ   rã   ræ   rû   r
  r  r  r  r   r   r.   r+   r*   Ú<module>rÉ     s×  ðÝ 2ç  „ ƒÛ 
Û ß #ß -Ý  Ý !ß @Õ @àÐ%Ñ&€æÝ$ãß\Ñ\Ý3ð €
Ø€	Ø€Ø€Ø€
Ø€Ø€	Ø€	ð	€ñ ˆCƒL€Ùˆv Ñ&€æØ
×Ñ˜'Ó!Øˆ
ò	/ô
	˜ô 	ô	Ð.ô 	ô	Ð!3ô 	ñ �4Ñô8=�w˜t‘}ó 8=ó ð8=ð| ÷ð ó ðð ÷&ð &ó ð&ð ÷	Gð 	Gó ð	Gð ÷ð ó ðð ÷#ð #ó ð#ð ÷^ ð ^ ó ð^ ôH/ô

Mð
Øð
àð
ð ð
ð ô	
ð0Øðàðð ôð@*Øð*àð*ð ô*ðZTMØ)ðTMà"ðTMð ôTMôn<ð~
EØð
Eà
ð
Eð #ð
Eð 
ô	
Eð?Øð?àð?ð 
ô?ð.GØðGàðGð #ðGð 
ô	Gô:|�sô |ð~ ô>
Ð+ó >
ó ñ>
r+   