diff --git a/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py b/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py index 82589e2..c114649 100644 --- a/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py +++ b/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py @@ -11,7 +11,7 @@ import os import logging -from typing import (Optional, Any, cast,) +from typing import (Optional, Any, cast, Type, TypeVar,) from typing_extensions import ( Self, BinaryIO, ) @@ -55,7 +55,26 @@ class PyProject: ) tool: dict[str, Any] = dataclasses.field( - default_factory=dict, + default_factory=lambda : dict(), + ) + +Key = TypeVar('Key') +Value = TypeVar('Value') + +def check_dict( + value: Any, + KT: Type[Key], + VT: Type[Value], +) -> dict[Key, Value]: + assert isinstance(value, dict) + value2 = cast(dict[Any, Any], value) + assert all([ + isinstance(k, KT) and isinstance(v, VT) + for k, v in value2.items() + ]) + return cast( + dict[Key, Value], + value, ) def pyproject_load( diff --git a/python/pyproject.toml b/python/pyproject.toml index 6cb5a70..c7fb665 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -114,10 +114,13 @@ include = [ #'../../../../../follow_the_leader/views2/payments.py', #'../../../../../follow_the_leader/logic/payments.py', #'../../../../../follow_the_leader/logic/paypal.py', - 'python', + 'online/fxreader/pr34/commands_typed/**/*.py', ] +# stubPath = '../mypy-stubs' extraPaths = [ - 'python', + '.', + '../mypy-stubs', + '../mypy-stubs/types-debugpy', # '../../../../../', ] #strict = ["src"]