sqlite-utils/sqlite_utils/plugins.py
Claude 83c50527aa
Add type hints to public APIs and configure mypy
- Improve mypy configuration with appropriate strictness settings
- Add comprehensive type hints to public API functions:
  - hookspecs.py: Type register_commands and prepare_connection hooks
  - plugins.py: Type get_plugins function and PluginManager
  - recipes.py: Type parsedate, parsedatetime, jsonsplit functions
  - utils.py: Type all public utility functions including rows_from_file,
    TypeTracker, ValueTracker, chunks, hash_record, flatten, etc.
  - db.py: Type Database, Queryable, Table, and View class methods
    including constructor, execute, query, table operations, etc.
- Exclude cli.py from strict checking (internal implementation detail)
- All public API modules now pass mypy type checking
2025-12-15 18:57:58 +00:00

29 lines
948 B
Python

from typing import Any, Dict, List
import pluggy
import sys
from . import hookspecs
pm: pluggy.PluginManager = pluggy.PluginManager("sqlite_utils")
pm.add_hookspecs(hookspecs)
if not getattr(sys, "_called_from_test", False):
# Only load plugins if not running tests
pm.load_setuptools_entrypoints("sqlite_utils")
def get_plugins() -> List[Dict[str, Any]]:
plugins: List[Dict[str, Any]] = []
plugin_to_distinfo = dict(pm.list_plugin_distinfo())
for plugin in pm.get_plugins():
hookcallers = pm.get_hookcallers(plugin)
plugin_info: Dict[str, Any] = {
"name": plugin.__name__,
"hooks": [h.name for h in hookcallers] if hookcallers else [],
}
distinfo = plugin_to_distinfo.get(plugin)
if distinfo:
plugin_info["version"] = distinfo.version
plugin_info["name"] = distinfo.project_name
plugins.append(plugin_info)
return plugins