o
    iQ                     @   s   d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
mZ edddZ	 G dd	 d	ee Ze
d
eee  ee B efdZ	 dee dee fddZeG dd dee Ze
dee dB efdZ	 dedefddZdS )zUtility types and functions for type manipulation and introspection.

This module provides helper classes and functions for working with Python's type system,
including workarounds for type checker limitations and utilities for runtime type inspection.
    )	dataclass)AnyGenericcastget_args
get_origin)TypeAliasTypeTypeVarTT)infer_variancec                   @   s   e Zd ZdZdS )TypeExpressionaa  A workaround for type checker limitations when using complex type expressions.

        This class serves as a wrapper for types that cannot normally be used in positions
    requiring `type[T]`, such as `Any`, `Union[...]`, or `Literal[...]`. It provides a
        way to pass these complex type expressions to functions expecting concrete types.

    Example:
            Instead of `output_type=Union[str, int]` (which may cause type errors),
            use `output_type=TypeExpression[Union[str, int]]`.

    Note:
            This is a workaround for the lack of TypeForm in the Python type system.
    N)__name__
__module____qualname____doc__ r   r   ^/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/pydantic_graph/beta/util.pyr      s    r   TypeOrTypeExpression)type_paramstype_returnc                 C   s&   t | tu rt| d S ttt | S )zExtract the actual type from a TypeExpression wrapper or return the type directly.

    Args:
        type_: Either a direct type or a TypeExpression wrapper.

    Returns:
        The unwrapped type, ready for use in runtime type operations.
    r   )r   r   r   r   typer
   )r   r   r   r   unpack_type_expression+   s   	r   c                   @   s   e Zd ZU dZeed< dS )SomeaB  Container for explicitly present values in Maybe type pattern.

    This class represents a value that is definitely present, as opposed to None.
    It's part of the Maybe pattern, similar to Option/Maybe in functional programming,
    allowing distinction between "no value" (None) and "value is None" (Some(None)).
    valueN)r   r   r   r   r
   __annotations__r   r   r   r   r   9   s   
 r   MaybeN	callable_c                 C   s   t | dt| S )zExtract a human-readable name from a callable object.

    Args:
        callable_: Any callable object (function, method, class, etc.).

    Returns:
        The callable's __name__ attribute if available, otherwise its string representation.
    r   )getattrstr)r   r   r   r   get_callable_nameQ   s   	r    )r   dataclassesr   typingr   r   r   r   r   typing_extensionsr   r	   r
   r   r   r   r   r   r   r   r    r   r   r   r   <module>   s     
