
    thi                        d dl mZ d dlZd dlZd dlmZ d dlmZ ddZ	 	 	 	 ddZ	ej                   G d d             Z G d	 d
e      Z G d d      Z	 	 	 	 	 	 ddZy)    )annotationsN)Mapping)Requirementc                L    t        j                  dd|       j                         S )Nz[-_.]+-)resublower)names    RD:\jyotish\venv\Lib\site-packages\pip/_vendor/dependency_groups/_implementation.py_normalize_namer   
   s    66)S$'--//    c                |   i }i }| j                         D ]6  \  }}t        |      }|j                  |g       j                  |       |||<   8 g }|j                         D ]:  \  }}t	        |      dkD  s|j                  | ddj                  |       d       < |rt        ddj                  |             |S )N   z (, )z"Duplicate dependency group names: )itemsr   
setdefaultappendlenjoin
ValueError)	dependency_groupsoriginal_namesnormalized_groups
group_namevaluenormed_group_nameerrorsnormed_namenamess	            r   _normalize_group_namesr"      s     ,.N.446
E+J7!!"3R8??
K/4+, 7
 F,224Uu:>MM[MDIIe,<+=Q?@ 5 =dii>O=PQRRr   c                      e Zd ZU ded<   y)DependencyGroupIncludestrinclude_groupN)__name__
__module____qualname____annotations__ r   r   r$   r$   #   s    r   r$   c                  $     e Zd ZdZd fdZ xZS )CyclicDependencyErrorz9
    An error representing the detection of a cycle.
    c                    || _         || _        || _        ||k(  r| d}n| d| d| d| }t        |   d| d|        y )Nz includes itselfz -> r   z0Cyclic dependency group include while resolving z: )requested_groupgroupr&   super__init__)selfr/   r0   r&   reason	__class__s        r   r2   zCyclicDependencyError.__init__-   sl    .
*E!w./F%d5'E7$}oNF>r&+	
r   )r/   r%   r0   r%   r&   r%   returnNone)r'   r(   r)   __doc__r2   __classcell__)r5   s   @r   r-   r-   (   s    
 
r   r-   c                  H    e Zd ZdZ	 	 	 	 ddZd	dZd
dZ	 	 	 	 d	dZddZy)DependencyGroupResolvera\  
    A resolver for Dependency Group data.

    This class handles caching, name normalization, cycle detection, and other
    parsing requirements. There are only two public methods for exploring the data:
    ``lookup()`` and ``resolve()``.

    :param dependency_groups: A mapping, as provided via pyproject
        ``[dependency-groups]``.
    c                    t        |t              st        d      t        |      | _        i | _        i | _        i | _        y )Nz(Dependency Groups table is not a mapping)
isinstancer   	TypeErrorr"   r   _parsed_groups_include_graph_ancestors_resolve_cache)r3   r   s     r   r2   z DependencyGroupResolver.__init__H   sJ     +W5FGG!78I!J  	 EG%BDr   c                p    t        |t              st        d      t        |      }| j	                  |      S )a  
        Lookup a group name, returning the parsed dependency data for that group.
        This will not resolve includes.

        :param group: the name of the group to lookup

        :raises ValueError: if the data does not appear to be valid dependency group
            data
        :raises TypeError: if the data is not a string
        :raises LookupError: if group name is absent
        :raises packaging.requirements.InvalidRequirement: if a specifier is not valid
        "Dependency group name is not a str)r=   r%   r>   r   _parse_groupr3   r0   s     r   lookupzDependencyGroupResolver.lookupX   s5     %%@AA&  ''r   c                r    t        |t              st        d      t        |      }| j	                  ||      S )a  
        Resolve a dependency group to a list of requirements.

        :param group: the name of the group to resolve

        :raises TypeError: if the inputs appear to be the wrong types
        :raises ValueError: if the data does not appear to be valid dependency group
            data
        :raises LookupError: if group name is absent
        :raises packaging.requirements.InvalidRequirement: if a specifier is not valid
        rC   )r=   r%   r>   r   _resolverE   s     r   resolvezDependencyGroupResolver.resolvej   s5     %%@AA&}}UE**r   c                   || j                   v r| j                   |   S || j                  vrt        d| d      | j                  |   }t        |t              st        d| d      g }|D ]  }t        |t              r|j                  t        |             .t        |t              rht        |j                               dk7  rt        d|       t        t        |j                                     }|j                  t!        |             t        d|        t        |      | j                   |<   | j                   |   S )NzDependency group 'z' not foundz' is not a list)zinclude-groupzInvalid dependency group item: )r&   )r?   r   LookupErrorr=   listr>   r%   r   r   dicttuplekeysr   nextitervaluesr$   )r3   r0   	raw_groupelementsitemr&   s         r   rD   z$DependencyGroupResolver._parse_group{   s3    D'''&&u--... 25'EFF**51	)T*0GHH?AD$$ D 12D$'%);;$'Ftf%MNN $T$++-%8 9 6] ST #B4&!IJJ  &+8_E"""5))r   c                p   || j                   v r| j                   |   S | j                  |      }g }|D ]  }t        |t              r|j	                  |       %t        |t
              rt        |j                        }|| j                  j                  |d      v rt        |||j                        g | j                  j                  |d      || j                  |<   |j                  | j                  ||             t        d|        t        |      | j                   |<   | j                   |   S )z
        This is a helper for cached resolution to strings.

        :param group: The name of the group to resolve.
        :param requested_group: The group which was used in the original, user-facing
            request.
        r+   z+Invalid dependency group item after parse: )rA   rD   r=   r   r   r$   r   r&   r@   getr-   extendrH   NotImplementedErrorrN   )r3   r0   r/   parsedresolved_grouprU   r&   s          r   rH   z DependencyGroupResolver._resolve   s<    D'''&&u--""5)D$,%%d+D"89 /0B0B C D$A$A$E$EeR$PP/'0B0B @2266ubA@@--m< %%dmmM?&ST)A$H  & &+>%:E"""5))r   N)r   %Mapping[str, str | Mapping[str, str]]r6   r7   )r0   r%   r6   z0tuple[Requirement | DependencyGroupInclude, ...])r0   r%   r6   tuple[Requirement, ...])r0   r%   r/   r%   r6   r]   )	r'   r(   r)   r8   r2   rF   rI   rD   rH   r+   r   r   r;   r;   <   sF    	E@E 
E ($+"**	9*B"*r   r;   c               B    t        |       t        fd|D              S )a  
    Resolve a dependency group to a tuple of requirements, as strings.

    :param dependency_groups: the parsed contents of the ``[dependency-groups]`` table
        from ``pyproject.toml``
    :param groups: the name of the group(s) to resolve

    :raises TypeError: if the inputs appear to be the wrong types
    :raises ValueError: if the data does not appear to be valid dependency group data
    :raises LookupError: if group name is absent
    :raises packaging.requirements.InvalidRequirement: if a specifier is not valid
    c              3  `   K   | ]%  }j                  |      D ]  }t        |        ' y w)N)rI   r%   ).0r0   rresolvers      r   	<genexpr>zresolve.<locals>.<genexpr>   s*     MVEX5E5Ee5LQ5LVs   +.)r;   rN   )r   groupsrb   s     @r   rI   rI      s!     ''89HMVMMMr   )r   r%   r6   r%   )r   r\   r6   r\   )r   r\   rd   r%   r6   ztuple[str, ...])
__future__r   dataclassesr   collections.abcr   "pip._vendor.packaging.requirementsr   r   r"   	dataclassr$   r   r-   r;   rI   r+   r   r   <module>rj      s    "  	 # :0<**   
J 
(B* B*JN<NJMNNr   