Ë
    èlÖiÎ  ã                  ó  — d dl mZ d dlZd dlZd dlmZmZ d dlmZm	Z	m
Z
mZmZmZmZ d dlmZ d dlmZmZ d dlmZmZ eZ G d„ d	e«      Z G d
„ de«      Z G d„ de«      Z edde¬«      Z edd¬«      Z G d„ deee   «      Zy)é    )ÚannotationsN)ÚABCÚabstractmethod)ÚAnyÚCallableÚClassVarÚ	GeneratorÚGenericÚTypeÚTypeVar)ÚParsingException)ÚPARSING_CONTEXT_KEYÚParsingContext)Ú	BaseModelÚroot_validatorc                  ó   — e Zd ZdZdd„Zy)ÚHashableBaseModelz/Extends BaseModel with a generic hash function.c                ób   — t        t        j                  | j                  d¬«      d¬«      «      S )NT)Ú	sort_keys)ÚhashÚjsonÚdumps©Úselfs    úq/var/www/html/strategist-ai/venv_dbt/lib/python3.12/site-packages/dbt_semantic_interfaces/implementations/base.pyÚ__hash__zHashableBaseModel.__hash__   s#   € Ü”D—J‘J˜tŸy™y°4˜yÓ8ÀDÔIÓJÐJó    N)ÚreturnÚint)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r   r      s   „ Ù9ôKr   r   c                  ó4   — e Zd ZdZ G d„ d«      Zdd„Zdd„Zy)ÚFrozenBaseModelz0Similar to HashableBaseModel but faux immutable.c                  ó   — e Zd ZdZdZy)úFrozenBaseModel.ConfigzPydantic feature.FN)r    r!   r"   r#   Úallow_mutationr$   r   r   ÚConfigr(      s
   „ Ùà‰r   r*   c                óz   — | j                  «       }t        j                  |«      }t        j                  |d¬«      S )z(Convert to a pretty JSON representation.é   )Úindent)r   Úloadsr   )r   Úraw_json_strÚjson_objs      r   Úto_pretty_jsonzFrozenBaseModel.to_pretty_json"   s,   € à—y‘y“{ˆÜ—:‘:˜lÓ+ˆÜ�z‰z˜(¨1Ô-Ð-r   c                ó"   — | j                  «       S )N)Ú__repr__r   s    r   Ú__str__zFrozenBaseModel.__str__(   s   € Ø�}‰}‹Ðr   N)r   Ústr)r    r!   r"   r#   r*   r1   r4   r$   r   r   r&   r&      s   „ Ù:÷ñ ó
.ôr   r&   c                  óJ   — e Zd ZU dZdZded<    ed¬«      ed	d„«       «       Zy)
ÚModelWithMetadataParsingaI  Pydantic model object with a root validator for converting ParsingContext into Metadata].

    To use this validator the model class in question MUST have a field with the following base
    specification:

      metadata: Optional[Metadata]

    This class does NOT define the metadata itself because Pydantic's parsing and validation can be
    dependent on the order in which the model properties are listed in the class definition.
    Therefore, we prefer to keep this generic and allow callers to add the metadata field wherever
    we encounter parsing context information.
    ÚmetadatazClassVar[str]Ú__METADATA_KEY__T)Úprec                óò  — t        |t        «      st        d|› d|› �«      ‚|j                  «       }| j                  |v r|S t
        |vr|S |j                  t
        «      }t        |t        «      st        dt        |«      › d|› d|› �«      ‚|j                  t        j                  j                  |j                  «      d   |j                  |j                  |j                   dœdœ|| j                  <   |S )	aÚ  Takes info from parsing context and converts it to a Metadata model object.

        Per Pydantic's processing logic, this runs on the collection of input data for whatever model
        object is doing its parser walk. Since we set pre to True this should happen before any of the
        properties in the model is allowed to access the input values, which allows us to update them
        to include the appropriate inputs for defined Metadata object properties.
        z;Input values should be an object (dict) type, but got type(z) with value: zGParsing context should always be a ParsingContext object, but we got a z with value: z inside payload: éÿÿÿÿ)ÚfilenameÚcontentÚstart_line_numberÚend_line_number)Úrepo_file_pathÚ
file_slice)Ú
isinstanceÚdictÚ
ValueErrorÚkeysr9   r   Úpopr   r   Útyper=   ÚosÚpathÚsplitr>   Ú
start_lineÚend_line)ÚclsÚvaluesrF   Úcontexts       r   Ú%extract_metadata_from_parsing_contextz>ModelWithMetadataParsing.extract_metadata_from_parsing_context<   s  € ô ˜&¤$Ô'ÜØMÈfÈXÐUcÐdjÐckÐlóð ð
 �{‰{‹}ˆØ×Ñ 4Ñ'àˆMä dÑ*ð ˆMà—*‘*Ô0Ó1ˆÜ˜'¤>Ô2Ü"ØYÔZ^Ð_fÓZgÐYhð iØ&˜iÐ'8¸¸ðBóð ð &×.Ñ.äŸG™GŸM™M¨'×*:Ñ*:Ó;¸BÑ?Ø"Ÿ?™?Ø%,×%7Ñ%7Ø#*×#3Ñ#3ñ	ñ(
ˆˆs×#Ñ#Ñ$ð ˆr   N)rO   ÚPydanticParseableValueTyper   rR   )	r    r!   r"   r#   r9   Ú__annotations__r   ÚclassmethodrQ   r$   r   r   r7   r7   ,   s3   … ñð '1Ð�mÓ0á˜ÔØò(ó ó ñ(r   r7   ÚModelObjectT_coT)Ú	covariantÚboundÚ	SelfTypeTÚPydanticCustomInputParser)rW   c                  óp   — e Zd ZdZe	 	 	 	 dd„«       Ze	 	 	 	 	 	 dd„«       Zee	 	 	 	 	 	 dd„«       «       Zy)rY   a�  Implements required methods for enabling custom parsing for Pydantic BaseModel objects.

    This abstract class helper is for the specific case where model object classes need to do custom parsing
    prior to object initialization, meaning that the inputs to the initializer itself must be parsed in a
    manner custom to the object, but without updating the input values for the rest of the model hierarchy.

    This class will NOT allow for custom handling of dict or object type inputs, assuming that they should be
    processed and validated in the standard Pydantic way. Any subclass needing to mutate the inputs from a dict
    or object type in a subclass-specific way should still be able to do so via the standard Pydantic approach
    of adding a method decorated with @validator or @root_validator, which will work internally to initialization
    and validation of that model object itself.
    c              #  ó(   K  — | j                   –— y­w)az  Pydantic magic method for allowing parsing of arbitrary input on parse_obj invocation.

        This allows for parsing and validation prior to object initialization. Most classes implementing this
        interface in our model are doing so because the input value from user-supplied YAML will be a string
        representation rather than the structured object type.
        N)Ú6_PydanticCustomInputParser__parse_with_custom_handling)rN   s    r   Ú__get_validators__z,PydanticCustomInputParser.__get_validators__|   s   è ø€ ð ×.Ñ.Ó.ùs   ‚c                óp   — t        |t        «      r | di |¤ŽS t        || «      r|S | j                  |«      S )a  Core method for handling common valid - or easily validated - input types.

        Pydantic objects can commonly appear as JSON object types (from, e.g., deserializing a Pydantic-serialized
        model) or direct instances of the model object class (from, e.g., initializing an object and passing it in
        to the initializer of a containing model object). This internal wrapper handles both of these cases in the
        standard Pydantic way of either validating the object type input on initialization, or passing the
        already-validated instance along as the output.

        Note this will also pass any Pydantic instance initialized via the `construct` method, which means it is
        possible for a caller to thread an unvalidated - and therefore improperly initialized - instance through.
        However, this is part of the contract with `construct` - it is only to be used when the inputs are known
        to the caller to be pre-validated, and so we do not bother guarding against that here.
        r$   )rC   rD   Ú_from_yaml_value©rN   Úinputs     r   Ú__parse_with_custom_handlingz6PydanticCustomInputParser.__parse_with_custom_handlingˆ   s:   € ô" �eœTÔ"Ù‘<˜‘<ÐÜ˜˜sÔ#ØˆLà×'Ñ'¨Ó.Ð.r   c                ó   — t        «       ‚)z<Abstract method for providing object-specific parsing logic.)ÚNotImplementedErrorr`   s     r   r_   z*PydanticCustomInputParser._from_yaml_value    s   € ô "Ó#Ð#r   N)rN   ú0Type[PydanticCustomInputParser[ModelObjectT_co]]r   ziGenerator[Callable[[PydanticParseableValueType], PydanticCustomInputParser[ModelObjectT_co]], None, None])rN   re   ra   rR   r   z*PydanticCustomInputParser[ModelObjectT_co])	r    r!   r"   r#   rT   r]   r\   r   r_   r$   r   r   rY   rY   n   s‹   „ ñð ð	/Ø=ð	/à	rò	/ó ð	/ð ð/Ø=ð/ØF`ð/à	3ò/ó ð/ð. Øð$Ø=ð$ØF`ð$à	3ò$ó ó ñ$r   )Ú
__future__r   r   rI   Úabcr   r   Útypingr   r   r   r	   r
   r   r   Údbt_semantic_interfaces.errorsr   Ú+dbt_semantic_interfaces.parsing.yaml_loaderr   r   Údsi_pydantic_shimr   r   rR   r   r&   r7   rU   rX   rY   r$   r   r   ú<module>rl      sˆ   ðÝ "ã Û 	ß #ß M× MÑ Må ;÷÷ 8ð !Ð ôK˜	ô KôÐ'ô ô$:˜yô :ñz Ð+°tÀ9ÔM€á�KÐ'BÔC€	ô8$  W¨_Ñ%=õ 8$r   