ó
    Eñi1*  ã                   ó
  • S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSr	/ SQr
\R                  " 5       rSS jr " S S\R                  5      rSSSS	.S
 jrS\S\4S jr " S S\R(                  5      rS\S\4S jrg)zU
lazy_loader
===========

Makes it easy to load subpackages and functions on demand.
é    Nz0.5)ÚattachÚattach_stubÚloadc                 óØ  ^ ^^	^
• Uc  0 nTc  [        5       mO[        T5      mUR                  5        VVVs0 s H  u  p4U  H  oUU_M     M     snnnm
[        TT
R                  5       -  5      m	U
U U4S jnU	4S jn[        R
                  R                  SS5      S;  nU(       a+  [        T
R                  5       5      T-   H  nU" U5        M     XgT	R                  5       4$ s  snnnf )a“  Attach lazily loaded submodules, functions, or other attributes.

Typically, modules import submodules and attributes as follows::

  import mysubmodule
  import anothersubmodule

  from .foo import someattr

The idea is to replace a package's `__getattr__`, `__dir__`, and
`__all__`, such that all imports work exactly the way they would
with normal imports, except that the import occurs upon first use.

The typical way to call this function, replacing the above imports, is::

  __getattr__, __dir__, __all__ = lazy.attach(
      __name__, ["mysubmodule", "anothersubmodule"], {"foo": ["someattr"]}
  )

Parameters
----------
package_name : str
    Typically use ``__name__``.
submodules : set
    List of submodules to attach.
submod_attrs : dict
    Dictionary of submodule -> list of attributes / functions.
    These attributes are imported as they are used.

Returns
-------
__getattr__, __dir__, __all__

c                 ó"  >• U T;   a  [         R                  " T SU  35      $ U T;   aW  T STU     3n[         R                  " U5      n[        X 5      nU TU    :X  a!  [        R                  T   nX4R
                  U '   U$ [        ST SU  35      e)NÚ.zNo z attribute )Ú	importlibÚimport_moduleÚgetattrÚsysÚmodulesÚ__dict__ÚAttributeError)ÚnameÚsubmod_pathÚsubmodÚattrÚpkgÚattr_to_modulesÚpackage_nameÚ
submoduless        €€€ÚQ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/lazy_loader/__init__.pyÚ__getattr__Úattach.<locals>.__getattr__I   s¥   ø€ Ø�:ÓÜ×*Ò*¨l¨^¸1¸T¸FÐ+CÓDÐDØ�_Ó$Ø)˜N¨!¨O¸DÑ,AÐ+BÐCˆKÜ×,Ò,¨[Ó9ˆFÜ˜6Ó(ˆDð
 � tÑ,Ó,Ü—k‘k ,Ñ/�Ø%)—‘˜TÑ"àˆKä  3 | n°KÀ¸vÐ!FÓGÐGó    c                  ó$   >• T R                  5       $ ©N)Úcopy)Ú__all__s   €r   Ú__dir__Úattach.<locals>.__dir__\   s   ø€ Ø�|‰|‹~Ðr   ÚEAGER_IMPORTÚ )Ú0r#   )ÚsetÚitemsÚsortedÚkeysÚosÚenvironÚgetr   )r   r   Úsubmod_attrsÚmodÚattrsr   r   r    Úeager_importr   r   s   ``       @@r   r   r      sÙ   û€ ðF ÑØˆàÑÜ“U‰
ä˜“_ˆ
ð %1×$6Ñ$6Ô$8õÚ$8‘j�cÄU¸TˆcŠ	ÁU‰Ñ$8ó€Oô �Z /×"6Ñ"6Ó"8Ñ8Ó9€G÷Hõ&ô —:‘:—>‘> .°"Ó5¸YÑF€LÞÜ˜×,Ñ,Ó.Ó/°*Ô<ˆDÙ˜Öñ =ð  §¡£Ð/Ð/ùôCs   ·C%c                   ó.   ^ • \ rS rSrU 4S jrS rSrU =r$ )ÚDelayedImportErrorModuleég   c                ó>   >• Xl         X l        [        TU ]  " U0 UD6  g r   )Ú%_DelayedImportErrorModule__frame_dataÚ"_DelayedImportErrorModule__messageÚsuperÚ__init__)ÚselfÚ
frame_dataÚmessageÚargsÚkwargsÚ	__class__s        €r   r7   Ú!DelayedImportErrorModule.__init__h   s    ø€ Ø&ÔØ ŒÜ‰Ò˜$Ð) &Ó)r   c                 óÄ   • U R                   n[        U R                   SUS    SUS    SUS    SSR                  US	   =(       d    S5      R	                  5        3	5      e)
NzF

This error is lazily reported, having originally occurred in
  File Úfilenamez, line Úlinenoz, in Úfunctionz

----> r#   Úcode_context)r4   ÚModuleNotFoundErrorr5   ÚjoinÚstrip)r8   ÚxÚfds      r   r   Ú$DelayedImportErrorModule.__getattr__m   sv   € Ø×ÑˆÜ!Ø�~‰~Ðð à˜‘nÐ% W¨R°©\¨N¸%ÀÀ:ÁÐ?Oð PØ—W‘W˜R Ñ/×5°2Ó6×<Ñ<Ó>Ð?ðAó
ð 	
r   )Ú__frame_dataÚ	__message)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r7   r   Ú__static_attributes__Ú__classcell__)r=   s   @r   r1   r1   g   s   ø† õ*÷

ð 
r   r1   F)ÚrequireÚerror_on_importÚsuppress_warningc                ó´  • [            [        R                  R                  U 5      nUSLnU(       a  Uc  UsSSS5        $ U(       d#  SU ;   a  Sn[        R
                  " U[        5        SnU(       d#  [        R                  R                  U 5      nUSLnU(       d  SU  S3nOUb   [        U5      nSU S3nU(       dm  U(       a  [        W5      eS	SKn
U
R                  5       S
   nUR                  UR                   UR"                  UR$                  S.nA['        USWS9sSSS5        $ Ubl  [        R                  R)                  U5      nU[        R                  U '   [        R                  R+                  UR,                  5      nUR/                  U5        SSS5        U$ ! [         a  n	[        SU  S35      U	eSn	A	ff = f! , (       d  f       W$ = f)aó  Return a lazily imported proxy for a module.

We often see the following pattern::

  def myfunc():
      import numpy as np
      np.norm(...)
      ....

Putting the import inside the function prevents, in this case,
`numpy`, from being imported at function definition time.
That saves time if `myfunc` ends up not being called.

This `load` function returns a proxy module that, upon access, imports
the actual module.  So the idiom equivalent to the above example is::

  np = lazy.load("numpy")

  def myfunc():
      np.norm(...)
      ....

The initial import time is fast because the actual import is delayed
until the first attribute is requested. The overall import time may
decrease as well for users that don't make use of large portions
of your library.

Warning
-------
While lazily loading *sub*packages technically works, it causes the
package (that contains the subpackage) to be eagerly loaded even
if the package is already lazily loaded.
So, you probably shouldn't use subpackages with this `load` feature.
Instead you should encourage the package maintainers to use the
`lazy_loader.attach` to make their subpackages load lazily.

Parameters
----------
fullname : str
    The full name of the module or submodule to import.  For example::

      sp = lazy.load("scipy")  # import scipy as sp

require : str
    A dependency requirement as defined in PEP-508.  For example::

      "numpy >=1.24"

    If defined, the proxy module will raise an error if the installed
    version does not satisfy the requirement.

error_on_import : bool
    Whether to postpone raising import errors until the module is accessed.
    If set to `True`, import errors are raised as soon as `load` is called.

suppress_warning : bool
    Whether to prevent emitting a warning when loading subpackages.
    If set to `True`, no warning will occur.

Returns
-------
pm : importlib.util._LazyModule
    Proxy module.  Can be used like any regularly imported module.
    Actual loading of the module occurs upon first attribute request.

Nr   zÄsubpackages can technically be lazily loaded, but it causes the package to be eagerly loaded even if it is already lazily loaded. So, you probably shouldn't use subpackages with this lazy feature.zNo module named 'Ú'zFound module 'zf' but cannot test requirement '{require}'. Requirements must match distribution name, not module name.z'No distribution can be found matching 'r   é   )r@   rA   rB   rC   r1   )r:   )Ú
threadlockr   r   r+   ÚwarningsÚwarnÚRuntimeWarningr	   ÚutilÚ	find_specÚ_check_requirementrD   Ú
ValueErrorÚinspectÚstackr@   rA   rB   rC   r1   Úmodule_from_specÚ
LazyLoaderÚloaderÚexec_module)ÚfullnamerR   rS   rT   ÚmoduleÚhave_moduleÚmsgÚspecÚnot_found_messageÚer`   Úparentr9   rd   s                 r   r   r   w   sÌ  € öF 
Ü—‘—‘ Ó*ˆØ DÐ(ˆö ˜7™?Ø÷ 
‰ö   C¨8£OðUð ô
 �MŠM˜#œ~Ô.àˆæÜ—>‘>×+Ñ+¨HÓ5ˆDØ dÐ*ˆKæØ"3°H°:¸QÐ ?ÑØÑ ðÜ0°Ó9�ð #JÈ'ÈÐRSÐ TÐæÞÜ)Ð*;Ó<Ð<Ûà—]‘]“_ QÑ'ˆFà"ŸO™OØ Ÿ-™-Ø"ŸO™OØ &× 3Ñ 3ñ	ˆJð Ü+ØØ*Ø)ñ÷c 
‰ðn ÑÜ—^‘^×4Ñ4°TÓ:ˆFØ$*ŒC�K‰K˜Ñ!ä—^‘^×.Ñ.¨t¯{©{Ó;ˆFØ×Ñ˜vÔ&÷y 
ð| €MøôG 'ó Ü Ø$ X Jð /Rð Róð ð	ûðú÷7 
Œð| €Mús>   ‡/GÁ A'GÂ(F&Â3A0GÄ-A/GÆ&
GÆ0G Ç GÇGÇ
GrR   Úreturnc                 óÂ   • SSK nSSKnUR                  R                  U 5      nUR                  R                  UR                  R                  UR                  5      SS9$ )am  Verify that a package requirement is satisfied

If the package is required, a ``ModuleNotFoundError`` is raised
by ``importlib.metadata``.

Parameters
----------
require : str
    A dependency requirement as defined in PEP-508

Returns
-------
satisfied : bool
    True if the installed version of the dependency matches
    the specified version, False otherwise.
r   NT)Úprereleases)	Úimportlib.metadataÚpackaging.requirementsÚrequirementsÚRequirementÚ	specifierÚcontainsÚmetadataÚversionr   )rR   r	   Ú	packagingÚreqs       r   r^   r^   û   sW   € ó" ã!à
×
 Ñ
 ×
,Ñ
,¨WÓ
5€CØ�=‰=×!Ñ!Ø×Ñ×"Ñ" 3§8¡8Ó,Øð "ð ð r   c                   ó@   • \ rS rSrSrS rS\R                  4S jrSr	g)Ú_StubVisitori  zAAST visitor to parse a stub file for submodules and submod_attrs.c                 ó0   • [        5       U l        0 U l        g r   )r%   Ú_submodulesÚ_submod_attrs)r8   s    r   r7   Ú_StubVisitor.__init__  s   € Ü›5ˆÔØˆÕr   Únodec                 ó¶  • UR                   S:w  a  [        S5      eUR                  (       a|  U R                  R	                  UR                  / 5      nUR
                   Vs/ s H  o3R                  PM     nnSU;   a  [        SUR                   S35      eUR                  U5        g U R                  R                  S UR
                   5       5        g s  snf )NrW   z;Only within-module imports are supported (`from .* import`)Ú*z4lazy stub loader does not support star import `from z
 import *`c              3   ó8   #   • U  H  oR                   v •  M     g 7fr   )r   )Ú.0Úaliass     r   Ú	<genexpr>Ú0_StubVisitor.visit_ImportFrom.<locals>.<genexpr>-  s   é € Ð#GºJ°5§J¦JºJùs   ‚)
Úlevelr_   rg   r   Ú
setdefaultÚnamesr   Úextendr~   Úupdate)r8   r�   r.   r†   Úaliasess        r   Úvisit_ImportFromÚ_StubVisitor.visit_ImportFrom  s¶   € Ø�:‰:˜‹?ÜØMóð ð �;�;Ø×,Ñ,×7Ñ7¸¿¹ÀRÓHˆEØ/3¯zªzÓ:ªz e—z”z©zˆGÐ:Ø�g‹~Ü ðØ!Ÿ[™[˜M¨ð5óð ð �L‰L˜Õ!à×Ñ×#Ñ#Ñ#G¸D¿JºJÓ#GÕGùò ;s   Á!C)r   r~   N)
rL   rM   rN   rO   Ú__doc__r7   ÚastÚ
ImportFromr�   rP   © r   r   r|   r|     s   † ÙKò ðH S§^¡^÷ Hr   r|   r   r@   c                 óê  • UR                  S5      (       a  UO$[        R                  R                  U5      S    S3n[        R                  R	                  U5      (       d  [        SU< 35      e[        U5       n[        R                  " UR                  5       5      nSSS5        [        5       nUR                  W5        [        XR                  UR                  5      $ ! , (       d  f       NI= f)aÓ  Attach lazily loaded submodules, functions from a type stub.

This is a variant on ``attach`` that will parse a `.pyi` stub file to
infer ``submodules`` and ``submod_attrs``. This allows static type checkers
to find imports, while still providing lazy loading at runtime.

Parameters
----------
package_name : str
    Typically use ``__name__``.
filename : str
    Path to `.py` file which has an adjacent `.pyi` file.
    Typically use ``__file__``.

Returns
-------
__getattr__, __dir__, __all__
    The same output as ``attach``.

Raises
------
ValueError
    If a stub file is not found for `filename`, or if the stubfile is formmated
    incorrectly (e.g. if it contains an relative import from outside of the module)
Úir   z.pyiz+Cannot load imports from non-existent stub N)Úendswithr)   ÚpathÚsplitextÚexistsr_   Úopenr’   ÚparseÚreadr|   Úvisitr   r~   r   )r   r@   ÚstubfileÚfÚ	stub_nodeÚvisitors         r   r   r   0  s»   € ð6 ×%Ñ% c×*Ñ*‰´2·7±7×3CÑ3CÀHÓ3MÈaÑ3PÐ2QÐQUÐ0Vð ô �7‰7�>‰>˜(×#Ñ#ÜÐFÀxÁlÐSÓTÐTä	ˆhŒ˜1Ü—I’I˜aŸf™f›hÓ'ˆ	÷ 
ô ‹n€GØ‡M�M�)ÔÜ�,× 3Ñ 3°W×5JÑ5JÓKÐK÷ 
�ús   Á<%C$Ã$
C2)NN)r‘   r’   r	   Úimportlib.utilr)   r   Ú	threadingÚtypesrY   Ú__version__r   ÚLockrX   r   Ú
ModuleTyper1   r   ÚstrÚboolr^   ÚNodeVisitorr|   r   r”   r   r   Ú<module>r¬      s    ðñó Û Û Û 	Û 
Û Û Û à€Ú
+€ð �^Š^Ó€
ôL0ô^
˜u×/Ñ/ô 
ð  #°EÈEõ AðH ð ¨ô ô8H�3—?‘?ô Hð2&L˜cð &L¨Sõ &Lr   