
    iT                    .   S SK Jr  S SKrS SKrS SKrS SKrS SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJrJr  S S	KJr  S S
KJr  \(       a  S SKJrJr  S SKJr  S SKJr  S V s/ s H  n \R;                  U 5      PM     sn rS V s/ s H  n \R;                  U 5      PM     sn rS V s/ s H  n \R;                  U 5      PM     sn r S V s/ s H  n \R;                  U 5      PM     sn r!\"\#S4   r$ \"\$\4   r% S#S jr&\ " S S5      5       r'\ " S S5      5       r( " S S5      r)\R:                  " S5      r*\R:                  " S5      r+\R:                  " S5      r,S$S jr-S%S jr.\ " S S 5      5       r/S&S! jr0S&S" jr1gs  sn f s  sn f s  sn f s  sn f )'    )annotationsN)defaultdict)suppress)	dataclass)chain)Path)TYPE_CHECKINGClassVar)UnhandledEditableModuleError)logger)IteratorSequence)Pattern)Module)z^__editables_\w+\.py$z^_editable_impl_\w+\.py$)z^__editable__\w+\.py$)z^_\w+_editable.py$)z^_\w+_editable_loader.py$.c                .   ^  [        U 4S jU 5       5      $ )Nc              3  D   >#    U  H  oR                  T5      v   M     g 7fN)match).0patternstrings     Q/home/james-whalen/.local/lib/python3.13/site-packages/griffe/_internal/finder.py	<genexpr>!_match_pattern.<locals>.<genexpr>4   s     =H}}V$$Hs    )any)r   patternss   ` r   _match_patternr   3   s    =H===    c                  @    \ rS rSr% SrS\S'    S\S'    SrS\S	'   S
rg)Package7   zThis class is a simple placeholder used during the process of finding packages.

Parameters:
    name: The package name.
    path: The package path(s).
    stubs: An optional path to the related stubs file (.pyi).
strnamer   pathNzPath | Nonestubs )__name__
__module____qualname____firstlineno____doc____annotations__r%   __static_attributes__r&   r   r   r    r    7   s&     I
JE;r   r    c                  0    \ rS rSr% SrS\S'    S\S'   Srg)	NamespacePackageI   zThis class is a simple placeholder used during the process of finding packages.

Parameters:
    name: The package name.
    path: The package paths.
r"   r#   
list[Path]r$   r&   N)r'   r(   r)   r*   r+   r,   r-   r&   r   r   r/   r/   I   s     I!
)r   r/   c                      \ rS rSr% Sr/ SQrS\S'    \" \5      rS\S'    SSS	 jjr	SS
 jr
SS jrSS jrSSS.       SS jjrSS jr S     S S jjrS!S jrS"S jrS#S jrS$S jrS%S jrS&S jrSrg)'ModuleFinderX   aR  The Griffe finder, allowing to find modules on the file system.

The module finder is generally not used directly.
Each [`GriffeLoader`][griffe.GriffeLoader] instance creates its own module finder instance.
The finder can be configured when instantiating the loader
thanks to the [loader][griffe.GriffeLoader]'s `search_paths` parameter.
).pyz.pycz.pyoz.pyd.pyiz.sozClassVar[list[str]]accepted_py_module_extensionszClassVar[set[str]]extensions_setNc                    0 U l         / U l         U=(       d    [        R                   H  nU R	                  [        U5      5        M     [        [        5      U l        U R                  5         g)zUInitialize the finder.

Parameters:
    search_paths: Optional paths to search into.
N)
_paths_contentssearch_pathssysr$   append_search_pathr   r   list_always_scan_for_extend_from_pth_files)selfr;   r$   s      r   __init__ModuleFinder.__init__f   s]     8:(*& !,CHH,D##DJ/ - 8C47H##%r   c                B    U R                  UR                  5       5        g)zAppend a search path.

The path will be resolved (absolute, normalized).
The path won't be appended if it is already in the search paths list.

Parameters:
    path: The path to append.
N)_append_search_pathresolverA   r$   s     r   r=   ModuleFinder.append_search_pathw   s     	  0r   c                Z    XR                   ;  a  U R                   R                  U5        g g r   )r;   appendrG   s     r   rE    ModuleFinder._append_search_path   s'    ((($$T* )r   c                z    UR                  5       nX R                  ;  a  U R                  R                  X5        gg)zInsert a search path at the given position.

The path will be resolved (absolute, normalized).
The path won't be inserted if it is already in the search paths list.

Parameters:
    position: The insert position in the list.
    path: The path to insert.
N)rF   r;   insert)rA   positionr$   s      r   insert_search_pathModuleFinder.insert_search_path   s4     ||~((($$X4 )r   TF)try_relative_pathfind_stubs_packagec                  [        U[        5      (       a%  U R                  U5      u  pEU R                  U5      nOMU(       a/   U R                  [        U5      5      u  pEU R                  U5      nOUnUR                  SS5      S   nU(       d  X@R                  U5      4$  U R                  U5      n U R                  US-   5      nUc  Uc  [        U5      eU(       a  U(       a  [        U[        5      (       a)  [        U[        5      (       a  UR                  Ul
        XG4$ [        U[        5      (       a4  [        U[        5      (       a  U=R                  UR                  -  sl	        XG4$ XG=(       d    U4$ ! [         a    UnUR                  SS5      S   n GNf = f! [         a    Sn GNf = f! [         a    Sn Nf = f)a}  Find the top-level parent module of a module.

If a Path is passed, only try to find the module as a file path.
If a string is passed, first try to find the module as a file path,
then look into the search paths.

Parameters:
    module: The module name or path.
    try_relative_path: Whether to try finding the module as a relative path,
        when the given module is not already a path.
    find_stubs_package: Whether to search for stubs-only package.
        If both the package and its stubs are found, they'll be merged together.
        If only the stubs are found, they'll be used as the package itself.

Raises:
    FileNotFoundError: When a Path was passed and the module could not be found:

        - the directory has no `__init__.py` file in it
        - the path does not exist

    ModuleNotFoundError: When a string was passed and the module could not be found:

        - no `module/__init__.py`
        - no `module.py`
        - no `module.pth`
        - no `module` directory (namespace packages)
        - or unsupported .pth file

Returns:
    The name of the module, and an instance representing its (namespace) package.
.   r   N-stubs)
isinstancer   _module_name_path_top_module_nameFileNotFoundErrorsplitfind_packageModuleNotFoundErrorr    r$   r%   r/   )	rA   modulerQ   rR   module_namemodule_pathtop_module_namepackager%   s	            r   	find_specModuleFinder.find_spec   s   N fd##'+'='=f'E$K"33K@OE+/+A+A$v,+O(
 #'"7"7"D K$ll3215O " 1 1/ BBB	''8G	%%o&@AE
 ?u}%o66 u'7++
5'0J0J %

 '' G%566:eM];^;^

*'' ,u,,I % :$"(,,sA"6q"9:  # 	G	 # 	E	s6   E= "F% 4F8 =!F"!F"%F54F58GGc                   [        U5      [        U S35      /nUnUR                  S5      n/ nU R                   GH  nU R                  U5      nU(       d  M  U H  nXW-  nX;   d  M  UR                  (       a8  UR                  S5      n	[        X8U	R                  5       (       a  U	OS5      s  s  $ US-  n
U
R                  5       (       aH  [        U
5      (       d8  U
R                  S5      n	[        X:U	R                  5       (       a  U	OS5      s  s  $ US-  n
U
R                  5       (       a  [        X:S5      s  s  $ UR                  U5        M     GM     U(       a  [        X5      $ [        U5      e)zFind a package or namespace package.

Parameters:
    module_name: The module name.

Raises:
    ModuleNotFoundError: When the module cannot be found.

Returns:
    A package or namespace package wrapper.
r5   rV   r6   N__init__.pyz__init__.pyi)r   removesuffixr;   	_contentssuffixwith_suffixr    exists_is_pkg_style_namespacerJ   r/   r]   )rA   r_   	filepathsreal_module_namenamespace_dirsr$   path_contentschoiceabs_pathr%   init_modules              r   r\   ModuleFinder.find_package   sX     K=$%
	 '+88B%%D NN40M}'F#}H0#??$,$8$8$@E#*+;PUP\P\P^P^udh#ii&.&>&--//8OP[8\8\$/$;$;F$CE#*+;SXS_S_SaSa%gk#ll&.&?&--//#*+;$#OO&--h7 ( && #K@@!+..r   c              #  ~  #    [        U[        5      (       a-  [        5       nU H  nU R                  X25       Sh  vN   M     gUR                  S:X  a  UR
                  nOUR                  U R                  ;   a  g[        U=(       d    S5      nU R                  U5       GH  nUR                  U5      nUR
                  U;   a  [        R                  " SU5        M>  UR                  S:H  nUR                  nU(       d  UR                  SS5      S   nUS:X  aP  [        UR                  5      S:X  a  M  UR                  SS	 U4v   Ub  UR                  UR
                  5        M  M  U(       a!  UR!                  S
5      R                  U4v   M  UR#                  U5      R                  U4v   GM     g GN7f)ai  Iterate on a module's submodules, if any.

Parameters:
    path: The module path.
    seen: If not none, this set is used to skip some files.
        The goal is to replicate the behavior of Python by
        only using the first packages (with `__init__` modules)
        of the same name found in different namespace packages.
        As soon as we find an `__init__` module, we add its parent
        path to the `seen` set, which will be reused when scanning
        the next namespace packages.

Yields:
    name_parts (tuple[str, ...]): The parts of a submodule name.
    filepath (Path): A submodule filepath.
NrB   r&   z'Skip %s, another module took precedencer5   rT   rU   r    )rW   r>   setiter_submodulesstemparentri   r8   _filter_py_modulesrelative_tor   debugr[   lenpartsaddrj   	with_name)	rA   r$   seen	path_elemskipsubpathrel_subpathpy_filerz   s	            r   ry   ModuleFinder.iter_submodules  s    * dD!! 5D!	//	@@@ "99
";;D [[D/// 4:2..t4G!--d3K!!T)FP!((E1G##Dzz#q)!,z! {(()Q.!'',g55#HH[//0 $!--b177@@!++D177@@- 5! As   9F=F:E?F=c           	         [        [        U R                  UR                  5      U R                  U R                  UR
                     5      5      [        S9$ )zReturn the list of a module's submodules.

Parameters:
    module: The parent module.

Returns:
    A list of tuples containing the parts of the submodule name and its path.
)key)sortedr   ry   filepathr?   r#   _module_depth)rA   r^   s     r   
submodulesModuleFinder.submodulesX  sM     $$V__5$$T%:%:6;;%GH 
 	
r   c                   UR                  5       nUR                  5       (       aN  U R                   H0  nUSU 3-  nUR                  5       (       d  M"  UR                  U4s  $    UR                  U4$ UR                  5       (       a6  UR
                  S:X  a  UR                  R                  U4$ UR
                  U4$ [        e)NrB   )absoluteis_dirr7   rk   r#   rz   r{   rZ   )rA   r$   extr`   s       r   rX   ModuleFinder._module_name_pathi  s    }};;==99"xu%55%%''99k11 : 99d?";;==yyJ&{{''--99d?"r   c                    XR                   ;  a'   [        UR                  5       5      U R                   U'   U R                   U   $ ! [        [        4 a    / U R                   U'    N0f = fr   )r:   r>   iterdirrZ   NotADirectoryErrorrG   s     r   rh   ModuleFinder._contentsx  sh    +++0-1$,,.-A$$T* ##D)) &'9: 0-/$$T*0s   &A A('A(c                l   U R                    H  nU R                  U5       H  nUR                  S:X  d  M  [        U5       Hh  nUR                  =n(       a7  U R
                  U   R                  UR                  R                  U5      5        U R                  UR                  5        Mj     M     M     g )Nz.pth)
r;   rh   ri   _handle_pth_filealways_scan_forr?   rJ   r$   joinpathr=   )rA   r$   item	directoryscans        r   r@   #ModuleFinder._extend_from_pth_files  s    %%Dt,;;&(%5d%;	#,#<#<<4< 11$7>>y~~?V?VW[?\]//	? &< - &r   c              #     #    [         R                  " USSS9 Hk  u  p#nU Vs/ s H  oUS:w  d  M
  UPM     snUS S & U HB  n[         R                  R                  U5      S   U R                  ;   d  M5  [        X&5      v   MD     Mm     g s  snf 7f)NT)topdownfollowlinks__pycache__rU   )oswalkr$   splitextr8   r   )rA   r$   rootdirsfilesdirrelfiles          r   r|   ModuleFinder._filter_py_modules  sy     !#t!ND&*Cds].BsdCDG 77##G,Q/43F3FFt-- ! "OCs   !B	B	B	9B3Bc                ~   UR                  5       (       a  UOUR                  nUR                  5       nU R                   HO  n[	        [
        [        5         UR                  UR                  5       5      nUR                  S   sS S S 5        s  $    UR                  U:w  ab  UR                  S-  R                  5       (       a@  UR                  nUR                  U:w  a$  UR                  S-  R                  5       (       a  M@  U R                  SUR                  5        UR                  $ ! , (       d  f       M  = f)Nr   rf   )r   r{   rF   r;   r   
ValueError
IndexErrorr}   r   rk   rO   r#   )rA   r$   parent_pathsearch_pathrel_paths        r   rY   ModuleFinder._top_module_name  s    "kkmmd!))+,,K*j1&22;3F3F3HI~~a( 21 -   K/[5G5G-5W4_4_4a4a%,,K   K/[5G5G-5W4_4_4a4a;#5#56 21s   .D--
D<	)r?   r:   r;   r   )r;   zSequence[str | Path] | NonereturnNone)r$   r   r   r   )rN   intr$   r   r   r   )r^   z
str | PathrQ   boolrR   r   r   z&tuple[str, Package | NamespacePackage])r_   r"   r   zPackage | NamespacePackage)r$   zPath | list[Path]r   z
set | Noner   zIterator[NamePartsAndPathType])r^   r   r   zlist[NamePartsAndPathType])r$   r   r   ztuple[str, Path])r$   r   r   r1   )r   r   )r$   r   r   zIterator[Path])r$   r   r   r"   )r'   r(   r)   r*   r+   r7   r,   rx   r8   rB   r=   rE   rO   rc   r\   ry   r   rX   rh   r@   r|   rY   r-   r&   r   r   r3   r3   X   s     :h!#6g5),-J)KN&K4&"	1+5$ #'#(Q-Q-  	Q-
 !Q- 
0Q-f-/d  @A@A @A 
(	@AD
" *@. r   r3   zG(?:__import__\([\"']pkg_resources[\"']\).declare_namespace\(__name__\))zP(?:__path__ = __import__\([\"']pkgutil[\"']\).extend_path\(__path__, __name__\))z^import[ \t]+\w+$c                    U R                  SS9n[        [        R                  U5      =(       d    [        R                  U5      5      $ )N	utf-8-sigencoding)	read_textr   _re_pkgresourcessearch_re_pkgutil)rs   codes     r   rl   rl     s<      + 6D ''-I1C1CD1IJJr   c                    [        U S   5      $ )Nr   )r   )name_parts_and_paths    r   r   r     s    "1%&&r   c                  .    \ rS rSr% S\S'   SrS\S'   Srg)	_SPi  r   r$   rw   r"   r   r&   N)r'   r(   r)   r*   r,   r   r-   r&   r   r   r   r     s    
JOSr   r   c                   / n U R                  SS9nUR                  5       R                  SS5      R	                  SS9 H  nUR                  5       n[
        R                  U5      (       aR  U R                  U[        S5      S  R                  5        S3-  n[        [        5         [        U5      sS S S 5        s  $ U(       d  M  UR                  S	5      (       a  M  [        R                  R!                  U5      (       d  M  UR#                  [%        ['        U5      5      5        M     U$ ! [         a    Us $ f = f! , (       d  f       N= f)
Nr   r   ;
Fkeependsimportr5   #)r   UnicodeDecodeErrorstripreplace
splitlines_re_import_liner   r{   r   lstripr   r   _handle_editable_module
startswithr   r$   rk   rJ   r   r   )r$   directoriestextlineeditable_modules        r   r   r     s     K ~~{~3 

$$S$/::E:Jzz|  &&"kktCMO/D/K/K/M.Nc,RRO67.? 874,,1E1Es4:/ K    87s   D/ (E/D>=D>
E	c           	        [        U R                  / [        Q[        Q75      (       a   U R	                  SS9R                  5       R                  SS9n[        US   R                  S5      S   5      nUR                  R                  S5      (       a   [        UR                  R                  5      /$ [        U5      /$ [        U R                  [        5      (       Ga`  [        R                   " U R	                  S	S95      nUR"                   GH,  n[%        U[        R&                  5      (       a  UR(                  S
   nO.[%        U[        R*                  5      (       a  UR,                  nOMa  [%        U[        R.                  5      (       d  M  UR0                  S:X  d  M  [%        UR2                  [        R4                  5      (       d  M  UR2                  R6                   Vs/ s HL  n[%        U[        R8                  5      (       d  M$  [        [        UR2                  5      R                  5      PMN     sns  $    [        U R                  [:        5      (       Gap  [        R                   " U R	                  S	S95      nUR"                   GH<  n[%        U[        R<                  5      (       d  M%  [%        UR2                  [        R>                  5      (       d  MP  [%        UR2                  R@                  [        R.                  5      (       d  M  UR2                  R@                  R0                  S:X  d  M  [%        UR2                  RB                  S   [        R8                  5      (       d  M  [        UR2                  RB                  S   R2                  S5      n[E        URG                  5       5      R                  n	[        XS9/s  $    [        U 5      e! [         a  n[        U 5      UeS nAff = fs  snf )Nr   r   Fr   rv   '   rB   utf8r   MAPPINGinstallrU   src)r   )$r   r#   _editable_editables_patterns$_editable_scikit_build_core_patternsr   r   r   rZ   r   r   r[   r   r   r{   _editable_setuptools_patternsastparsebodyrW   Assigntargets	AnnAssigntargetNameidvalueDictvaluesConstant_editable_meson_python_patternsExprCallfuncargsnextr   )
r$   editable_lineserrornew_pathparsed_modulenoder   cst
build_pathpkg_names
             r   r   r     s   dii!g#?!gBf!ghh
	@!^^[^AGGITT^cTdN r*005a89==##J//../00Hdii!>?? 		$..&."AB!&&D$

++aD#--00&#((++		Y0F:VZV`V`bebjbjKkKk?Czz?P?Pr?PT^_bdgdpdpTq3DO223?Prr ' dii!@AA 		$..&."AB!&&D4**tzz38844tzz99JJOO&&)3tzzq13<<@@!$**//!"4":":EB

 2 2 45::JABB ' 't
,,K ! 	@.t4%?	@& ss#   *O &#O9,O9
O6%O11O6)r   r"   r   zSequence[Pattern]r   r   )rs   r   r   r   )r   NamePartsAndPathTyper   r   )r$   r   r   z	list[_SP])2
__future__r   r   r   rer<   collectionsr   
contextlibr   dataclassesr   	itertoolsr   pathlibr   typingr	   r
   griffe._internal.exceptionsr   griffe._internal.loggerr   collections.abcr   r   r   griffe._internal.modelsr   compiler   r   r   r   tupler"   NamePartsTyper   r   r    r/   r3   r   r   r   rl   r   r   r   r   )pats   0r   <module>r     s  " # 
 	 	 
 #  !   * D *2. <ss;rC

3;rs <W X<WSC<W X C['\C[C

3C['\ $>]"^>]s2::c?>]"^ c3h 0]D01  =>   " * * *G  G T
 ::hi jjlm**12
K
'   
<--]  t X'\"^s   (F
F,FF