From 9380112892770f61402e4b539749e0fea03b985e Mon Sep 17 00:00:00 2001 From: afourney Date: Wed, 5 Mar 2025 22:24:08 -0800 Subject: [PATCH] Fixed loading of plugins. (#1096) --- packages/markitdown-sample-plugin/pyproject.toml | 2 +- .../src/markitdown_sample_plugin/__about__.py | 2 +- packages/markitdown/src/markitdown/__about__.py | 2 +- packages/markitdown/src/markitdown/_markitdown.py | 8 +++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/markitdown-sample-plugin/pyproject.toml b/packages/markitdown-sample-plugin/pyproject.toml index a12b9aa..400cc4f 100644 --- a/packages/markitdown-sample-plugin/pyproject.toml +++ b/packages/markitdown-sample-plugin/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ "Programming Language :: Python :: Implementation :: PyPy", ] dependencies = [ - "markitdown>=0.2.0a1", + "markitdown>=0.2.0a2", "striprtf", ] diff --git a/packages/markitdown-sample-plugin/src/markitdown_sample_plugin/__about__.py b/packages/markitdown-sample-plugin/src/markitdown_sample_plugin/__about__.py index ca1bba5..f691daf 100644 --- a/packages/markitdown-sample-plugin/src/markitdown_sample_plugin/__about__.py +++ b/packages/markitdown-sample-plugin/src/markitdown_sample_plugin/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2024-present Adam Fourney # # SPDX-License-Identifier: MIT -__version__ = "0.2.0a1" +__version__ = "0.2.0a2" diff --git a/packages/markitdown/src/markitdown/__about__.py b/packages/markitdown/src/markitdown/__about__.py index ca1bba5..f691daf 100644 --- a/packages/markitdown/src/markitdown/__about__.py +++ b/packages/markitdown/src/markitdown/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2024-present Adam Fourney # # SPDX-License-Identifier: MIT -__version__ = "0.2.0a1" +__version__ = "0.2.0a2" diff --git a/packages/markitdown/src/markitdown/_markitdown.py b/packages/markitdown/src/markitdown/_markitdown.py index 6086eb9..d88bb73 100644 --- a/packages/markitdown/src/markitdown/_markitdown.py +++ b/packages/markitdown/src/markitdown/_markitdown.py @@ -58,10 +58,10 @@ PRIORITY_GENERIC_FILE_FORMAT = ( ) -_plugins: List[Any] = [] +_plugins: Union[None, List[Any]] = None # If None, plugins have not been loaded yet. -def _load_plugins() -> List[Any]: +def _load_plugins() -> Union[None, List[Any]]: """Lazy load plugins, exiting early if already loaded.""" global _plugins @@ -186,7 +186,9 @@ class MarkItDown: """ if not self._plugins_enabled: # Load plugins - for plugin in _load_plugins(): + plugins = _load_plugins() + assert plugins is not None + for plugin in plugins: try: plugin.register_converters(self, **kwargs) except Exception: