mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-04 08:24:20 +02:00
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
This commit is contained in:
parent
fd5b09f64b
commit
83c50527aa
6 changed files with 226 additions and 126 deletions
|
|
@ -1,8 +1,10 @@
|
|||
from typing import Any, Dict, List
|
||||
|
||||
import pluggy
|
||||
import sys
|
||||
from . import hookspecs
|
||||
|
||||
pm = pluggy.PluginManager("sqlite_utils")
|
||||
pm: pluggy.PluginManager = pluggy.PluginManager("sqlite_utils")
|
||||
pm.add_hookspecs(hookspecs)
|
||||
|
||||
if not getattr(sys, "_called_from_test", False):
|
||||
|
|
@ -10,13 +12,14 @@ if not getattr(sys, "_called_from_test", False):
|
|||
pm.load_setuptools_entrypoints("sqlite_utils")
|
||||
|
||||
|
||||
def get_plugins():
|
||||
plugins = []
|
||||
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():
|
||||
plugin_info = {
|
||||
hookcallers = pm.get_hookcallers(plugin)
|
||||
plugin_info: Dict[str, Any] = {
|
||||
"name": plugin.__name__,
|
||||
"hooks": [h.name for h in pm.get_hookcallers(plugin)],
|
||||
"hooks": [h.name for h in hookcallers] if hookcallers else [],
|
||||
}
|
||||
distinfo = plugin_to_distinfo.get(plugin)
|
||||
if distinfo:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue