mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 01:44:31 +02:00
- 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
29 lines
948 B
Python
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
|