L iddlmZddlZddlZddlmZddlmZerddlmZdZGddZ d d Z Gd d ejZ y) ) annotationsN)Any) TYPE_CHECKING) TracebackTypeza Could not find `optuna-integration` for `{0}`. Please run `pip install optuna-integration[{0}]`.cHeZdZdZddZd dZ d dZd dZddZy) &_DeferredImportExceptionContextManagerzContext manager to defer exceptions from imports. Catches :exc:`ImportError` and :exc:`SyntaxError`. If any exception is caught, this class raises an :exc:`ImportError` when being checked. cd|_yN _deferredselfs U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/optuna/_imports.py__init__z/_DeferredImportExceptionContextManager.__init__s 7;c|S)zJEnter the context manager. Returns: Itself. r s r __enter__z0_DeferredImportExceptionContextManager.__enter__s  rct|ttfrft|trdj|j|}n/t|trdj|j |}nJ||f|_yy)aExit the context manager. Args: exc_type: Raised exception type. :obj:`None` if nothing is raised. exc_value: Raised exception object. :obj:`None` if nothing is raised. traceback: Associated traceback. :obj:`None` if nothing is raised. Returns: :obj:`None` if nothing is deferred, otherwise :obj:`True`. :obj:`True` will suppress any exceptions avoiding them from propagating. zTried to import '{}' but failed. Please make sure that the package is installed correctly to use this feature. Actual error: {}.zTried to import a package but failed due to a syntax error in {}. Please make sure that the Python version is correct to use this feature. Actual error: {}.TN) isinstance ImportError SyntaxErrorformatnamefilenamer )rexc_type exc_value tracebackmessages r__exit__z/_DeferredImportExceptionContextManager.__exit__&s{* i+{!; <)[1Q&3I{3!&++Y7  u'1DNrc|jduS)zReturn whether the context manager has caught any exceptions. Returns: :obj:`True` if no exceptions are caught, :obj:`False` otherwise. Nr r s r is_successfulz4_DeferredImportExceptionContextManager.is_successfulNs~~%%rcR|j|j\}}t||y)zCheck whether the context manager has caught any exceptions. Raises: :exc:`ImportError`: If any exception was caught from the caught exception. N)r r)rrrs rcheckz,_DeferredImportExceptionContextManager.checkWs. >> %!% Iwg&I 5 &rN)returnNone)r%z('_DeferredImportExceptionContextManager')rztype[Exception] | NonerzException | NonerzTracebackType | Noner%z bool | None)r%bool) __name__ __module__ __qualname____doc__rrr r"r$rrrrrsG<&(&$&( &  &P& 6rrctS)zCreate a context manager that can wrap imports of optional packages to defer exceptions. Returns: Deferred import context manager. )rrrr try_importr-ds  2 33rc4eZdZdZdfd ZddZddZxZS) _LazyImportaModule wrapper for lazy import. This class wraps the specified modules and lazily imports them only when accessed. Otherwise, `import optuna` is slowed down by importing all submodules and dependencies even if not required. Within this project's usage, importlib override this module's attribute on the first access and the imported submodule is directly accessed from the second access. Args: name: Name of module to apply lazy import. c2t||||_yr )superr_name)rr __class__s rrz_LazyImport.__init__{s  rctj|j}|jj |j|Sr ) importlib import_moduler2__dict__update)rmodules r_loadz_LazyImport._loads1((4 V__- rc6t|j|Sr )getattrr:)ritems r __getattr__z_LazyImport.__getattr__stzz|T**r)rstrr%r&)r%ztypes.ModuleType)r=r?r%r)r(r)r*r+rr:r> __classcell__)r3s@rr/r/ns  +rr/)r%r) __future__rr5typestypingrrr"_INTEGRATION_IMPORT_ERROR_TEMPLATErr- ModuleTyper/rrrrFsJ"  #8# O6O6d4+%""+r