REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.09 KB
Close
/opt/hc_python/lib64/python3.12/site-packages/pydantic/plugin/_loader.py
Text
Base64
from __future__ import annotations import importlib.metadata as importlib_metadata import os import warnings from typing import TYPE_CHECKING, Final, Iterable if TYPE_CHECKING: from . import PydanticPluginProtocol PYDANTIC_ENTRY_POINT_GROUP: Final[str] = 'pydantic' # cache of plugins _plugins: dict[str, PydanticPluginProtocol] | None = None # return no plugins while loading plugins to avoid recursion and errors while import plugins # this means that if plugins use pydantic _loading_plugins: bool = False def get_plugins() -> Iterable[PydanticPluginProtocol]: """Load plugins for Pydantic. Inspired by: https://github.com/pytest-dev/pluggy/blob/1.3.0/src/pluggy/_manager.py#L376-L402 """ disabled_plugins = os.getenv('PYDANTIC_DISABLE_PLUGINS') global _plugins, _loading_plugins if _loading_plugins: # this happens when plugins themselves use pydantic, we return no plugins return () elif disabled_plugins in ('__all__', '1', 'true'): return () elif _plugins is None: _plugins = {} # set _loading_plugins so any plugins that use pydantic don't themselves use plugins _loading_plugins = True try: for dist in importlib_metadata.distributions(): for entry_point in dist.entry_points: if entry_point.group != PYDANTIC_ENTRY_POINT_GROUP: continue if entry_point.value in _plugins: continue if disabled_plugins is not None and entry_point.name in disabled_plugins.split(','): continue try: _plugins[entry_point.value] = entry_point.load() except (ImportError, AttributeError) as e: warnings.warn( f'{e.__class__.__name__} while loading the `{entry_point.name}` Pydantic plugin, ' f'this plugin will not be installed.\n\n{e!r}' ) finally: _loading_plugins = False return _plugins.values()
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 3
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__pycache__
DIR
-
drwxr-xr-x
2025-04-04 08:02:07
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
_loader.py
2.09 KB
lrw-r--r--
2025-04-04 08:02:07
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
_schema_validator.py
5.12 KB
lrw-r--r--
2025-04-04 08:02:07
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
5.97 KB
lrw-r--r--
2025-04-04 08:02:07
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).