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
|
|
|
from typing import Any, Dict, List
|
|
|
|
|
|
2023-07-22 12:04:31 -07:00
|
|
|
import pluggy
|
|
|
|
|
import sys
|
|
|
|
|
from . import hookspecs
|
|
|
|
|
|
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
|
|
|
pm: pluggy.PluginManager = pluggy.PluginManager("sqlite_utils")
|
2023-07-22 12:04:31 -07:00
|
|
|
pm.add_hookspecs(hookspecs)
|
|
|
|
|
|
2023-07-22 16:21:27 -07:00
|
|
|
if not getattr(sys, "_called_from_test", False):
|
2023-07-22 12:04:31 -07:00
|
|
|
# Only load plugins if not running tests
|
|
|
|
|
pm.load_setuptools_entrypoints("sqlite_utils")
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
def get_plugins() -> List[Dict[str, Any]]:
|
|
|
|
|
plugins: List[Dict[str, Any]] = []
|
2023-07-22 12:04:31 -07:00
|
|
|
plugin_to_distinfo = dict(pm.list_plugin_distinfo())
|
|
|
|
|
for plugin in pm.get_plugins():
|
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
|
|
|
hookcallers = pm.get_hookcallers(plugin)
|
|
|
|
|
plugin_info: Dict[str, Any] = {
|
2023-07-22 12:04:31 -07:00
|
|
|
"name": plugin.__name__,
|
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
|
|
|
"hooks": [h.name for h in hookcallers] if hookcallers else [],
|
2023-07-22 12:04:31 -07:00
|
|
|
}
|
|
|
|
|
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
|