o
    wi
                     @  s   d dl mZ d dlmZmZ d dlmZmZmZm	Z	m
Z
 er6edZededZe	ee eee df f Ze
ddddZe
dd ddZeeffd!ddZd"ddZ		d#d$ddZdS )%    )annotations)HashableIterable)TYPE_CHECKINGAnyTypeVarUnionoverloadT	HashableT)bound.objIterable[T]	base_type	ClassInforeturnlist[T]c                 C     d S N r   r   r   r   D/home/ubuntu/.local/lib/python3.10/site-packages/wandb/_iterutils.pyalways_list      r   c                 C  r   r   r   r   r   r   r   r      r   r   c                 C  s   t | |r| gS t| S )ak  Return a guaranteed list of objects from one instance OR an iterable of such items.

    By default, assume the returned list should have string-like elements (`str`/`bytes`).

    Adapted from `more_itertools.always_iterable`, but simplified for internal use.  See:
    https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.always_iterable
    )
isinstancelistr   r   r   r   r      s   iterableIterable[HashableT]list[HashableT]c                 C  s   t t| S )zNReturn a deduplicated list of items from the given iterable, preserving order.)r   dictfromkeys)r   r   r   r   unique_list   s   r!   N	too_short"type[Exception] | Exception | Nonetoo_longc                 C  sd   t | }zt|}W n ty   |ptddw zt|}W n ty*   | Y S w |p0tdd)a  Return the only item in the iterable.

    Note:
        This is intended **only** as an internal helper/convenience function,
        and its implementation is directly adapted from `more_itertools.one`.
        Users needing similar functionality are strongly encouraged to use
        that library instead:
        https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.one

    Args:
        iterable: The iterable to get the only item from.
        too_short: Custom exception to raise if the iterable has no items.
        too_long: Custom exception to raise if the iterable has multiple items.

    Raises:
        ValueError or `too_short`: If the iterable has no items.
        ValueError or `too_long`: If the iterable has multiple items.
    z"Expected 1 item in iterable, got 0Nz)Expected 1 item in iterable, got multiple)iternextStopIteration
ValueError)r   r"   r$   itr   _r   r   r   one!   s   
r+   ).)r   r   r   r   r   r   )r   r
   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   )NN)r   r   r"   r#   r$   r#   r   r
   )
__future__r   collections.abcr   r   typingr   r   r   r   r	   r
   r   typetupler   r   strbytesr!   r+   r   r   r   r   <module>   s     
