o
    qoi	                     @   s   d Z ddlZddlZddlmZ ddlmZ ddlmZ e Z	deej
 dejdej
fd	d
Zdd ZejejejejgddD ]	\ZZeee q@dS )z0Utilities for type casting various fiddle types.    N)Type)config)partialnew_type	buildablereturnc                 C   sn   t |tjstd| t | tst| tjrtd| t|}|| ftvr0td||  | j	|
  S )az  Returns a copy of ``buildable`` that has been converted to ``new_type``.

  Requires that ``type(buildable)`` and ``type(new_type)`` be compatible.
  If the types may not be compatible, a warning will be issued, but the
  conversion will be attempted.

  Args:
    new_type: The type to convert to.
    buildable: The ``config.Buildable`` that should be copied and converted.
  z3Expected `buildable` to be a config.Buildable, got z>Expected `new_type` to be a subclass of config.Buildable, got zConversion from %s to %s has not been marked as officially supported.  If you think this conversion should be supported, contact the Fiddle team.)
isinstancer   	Buildable	TypeErrortype
issubclass_SUPPORTED_CASTSloggingwarning__unflatten____flatten__)r   r   src_type r   G/home/ubuntu/.local/lib/python3.10/site-packages/fiddle/_src/casting.pycast   s$   	r   c                 C   s   t | |f d S )N)r   add)r   dst_typer   r   r   register_supported_cast@   s   r      )repeat)__doc__	itertoolsr   typingr   fiddle._srcr   r   setr   
BuildableTr	   r   r   productConfigPartial
ArgFactory	_src_type	_dst_typer   r   r   r   <module>   s(   
$