core: feature: guess module stats from typing annotations

This commit is contained in:
Dima Gerasimov 2021-03-08 02:52:30 +00:00 committed by karlicoss
parent 4db81ca362
commit 8d6f691824
3 changed files with 104 additions and 0 deletions

View file

@ -240,6 +240,7 @@ def modules_check(args: Namespace) -> None:
tabulate_warnings()
from .util import get_stats, HPIModule
from .stats import guess_stats
mods: Iterable[HPIModule]
if module is None:
@ -265,7 +266,12 @@ def modules_check(args: Namespace) -> None:
continue
info(f'{color.GREEN}OK{color.RESET} : {m:<50}')
# first try explicitly defined stats function:
stats = get_stats(m)
if stats is None:
# then try guessing.. not sure if should log somehow?
stats = guess_stats(m)
if stats is None:
eprint(" - no 'stats' function, can't check the data")
# todo point to a readme on the module structure or something?