ó
    °Éi^  ã                  ó–   • S SK Jr  S SKrS SKJr  S SKJr  S SKJrJ	r	  \(       a  S SK
JrJr  S SKJr  SS jr\SS	 j5       rSSS
 jjrg)é    )ÚannotationsN)Úcontextmanager)Úimport_module)ÚTYPE_CHECKINGÚAny)ÚIteratorÚSequence)ÚPathc                óf   • S[         R                  < SU< SU R                  R                   SU  3$ )NzWith sys.path = z, accessing z raises z: )ÚsysÚpathÚ	__class__Ú__name__)ÚerrorÚobjpaths     ÚS/home/james-whalen/.local/lib/python3.13/site-packages/griffe/_internal/importer.pyÚ_error_detailsr      s3   € ØœcŸh™h™\¨°g±[ÀÈÏÉ×IaÑIaÐHbÐbdÐejÐdkÐlÐló    c               '  óØ   #   • U (       d  Sv •  g[         R                  nU  Vs/ s H  n[        U5      PM     sn[         l         Sv •  U[         l        gs  snf ! U[         l        f = f7f)z³Redefine `sys.path` temporarily.

Parameters:
    *paths: The paths to use when importing modules.
        If no paths are given, keep `sys.path` untouched.

Yields:
    Nothing.
N)r   r   Ústr)ÚpathsÚold_pathr   s      r   Úsys_pathr      sQ   é € ö ÛØÜx‰x€HÙ&+Ó,¢e˜d”D–	¡eÑ,„C„HðÛàŒùò	 -øð Œüs'   ‚!A*£A¸A*ÁA Á	A*ÁA'Á'A*c                ó¢  • U R                  S5      n/ n/ n[        U=(       d    S6    U(       a  SR                  U5      n [        U5      nO[        SR                  U5      5      eUnU H  n	 [        X‰5      nM     SSS5        U$ ! [         aE  nUR                  [        Xu5      5        UR                  SUR                  S5      5         SnAOSnAff = fU(       a  M´  N—! [         aN  nUR                  [        XuS-   SR                  U5      -   5      5        [        SR                  U5      5      eSnAff = f! , (       d  f       W$ = f)aû  Dynamically import the specified object.

It can be a module, class, method, function, attribute, type alias,
nested arbitrarily.

It works like this:

- for a given object path `a.b.x.y`
- it tries to import `a.b.x.y` as a module (with `importlib.import_module`)
- if it fails, it tries again with `a.b.x`, storing `y`
- then `a.b`, storing `x.y`
- then `a`, storing `b.x.y`
- if nothing worked, it raises an error
- if one of the iteration worked, it moves on, and...
- it tries to get the remaining (stored) parts with `getattr`
- for example it gets `b` from `a`, then `x` from `b`, etc.
- if a single attribute access fails, it raises an error
- if everything worked, it returns the last obtained attribute

Since the function potentially tries multiple things before succeeding,
all errors happening along the way are recorded, and re-emitted with
an `ImportError` when it fails, to let users know what was tried.

IMPORTANT: The paths given through the `import_paths` parameter are used
to temporarily patch `sys.path`: this function is therefore not thread-safe.

IMPORTANT: The paths given as `import_paths` must be *correct*.
The contents of `sys.path` must be consistent to what a user of the imported code
would expect. Given a set of paths, if the import fails for a user, it will fail here too,
with potentially unintuitive errors. If we wanted to make this function more robust,
we could add a loop to "roll the window" of given paths, shifting them to the left
(for example: `("/a/a", "/a/b", "/a/c/")`, then `("/a/b", "/a/c", "/a/a/")`,
then `("/a/c", "/a/a", "/a/b/")`), to make sure each entry is given highest priority
at least once, maintaining relative order, but we deem this unnecessary for now.

Parameters:
    import_path: The path of the object to import.
    import_paths: The (sys) paths to import the object from.

Raises:
    ModuleNotFoundError: When the object's module could not be found.
    ImportError: When there was an import error or when couldn't get the attribute.

Returns:
    The imported object.
Ú.© r   éÿÿÿÿNz; Ú:)Úsplitr   Újoinr   ÚBaseExceptionÚappendr   ÚinsertÚpopÚImportErrorÚgetattr)
Úimport_pathÚimport_pathsÚmodule_partsÚobject_partsÚerrorsÚmodule_pathÚmoduler   ÚvalueÚparts
             r   Údynamic_importr0   +   s6  € ð^ *×/Ñ/°Ó4€LØ €LØ€Fä	L×& BÒ	(ÞØŸ(™( <Ó0ˆKðÜ& {Ó3ð ä˜dŸi™i¨Ó/Ó0Ð0ð ˆÛ ˆDð5Ü Ó,’ñ !÷- 
)ð: €Løô1 !ó =ð —‘œn¨UÓ@ÔAØ×#Ñ# A |×'7Ñ'7¸Ó';×<Ñ<ûð	=ú÷	 ‰løô0 !ó 5Ø—‘œn¨UÀ#Ñ4EÈÏÉÐQ]ÓH^Ñ4^Ó_Ô`Ü! $§)¡)¨FÓ"3Ó4Ð4ûð5ú÷3 
)Ô	(ð: €LúsZ   §D?ÁBÁ"D?Á/C$Á:D?Â
CÂ;CÃD?ÃCÃ
D?Ã$
D<Ã.A	D7Ä7D<Ä<D?Ä?
E)r   r!   r   r   Úreturnr   )r   z
str | Pathr1   zIterator[None])N)r'   r   r(   zSequence[str | Path] | Noner1   r   )Ú
__future__r   r   Ú
contextlibr   Ú	importlibr   Útypingr   r   Úcollections.abcr   r	   Úpathlibr
   r   r   r0   r   r   r   Ú<module>r8      s?   ðõ
 #ã 
Ý %Ý #ß %æß2Ýômð óó ð÷*Pr   