[+] improve typing

This commit is contained in:
Siarhei Siniak 2025-05-19 11:38:25 +03:00
parent 6a2b14d8b9
commit 9f4b426229
2 changed files with 26 additions and 4 deletions

@ -11,7 +11,7 @@ import os
import logging import logging
from typing import (Optional, Any, cast,) from typing import (Optional, Any, cast, Type, TypeVar,)
from typing_extensions import ( from typing_extensions import (
Self, BinaryIO, Self, BinaryIO,
) )
@ -55,7 +55,26 @@ class PyProject:
) )
tool: dict[str, Any] = dataclasses.field( 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( def pyproject_load(

@ -114,10 +114,13 @@ include = [
#'../../../../../follow_the_leader/views2/payments.py', #'../../../../../follow_the_leader/views2/payments.py',
#'../../../../../follow_the_leader/logic/payments.py', #'../../../../../follow_the_leader/logic/payments.py',
#'../../../../../follow_the_leader/logic/paypal.py', #'../../../../../follow_the_leader/logic/paypal.py',
'python', 'online/fxreader/pr34/commands_typed/**/*.py',
] ]
# stubPath = '../mypy-stubs'
extraPaths = [ extraPaths = [
'python', '.',
'../mypy-stubs',
'../mypy-stubs/types-debugpy',
# '../../../../../', # '../../../../../',
] ]
#strict = ["src"] #strict = ["src"]