general: small updates for typing while trying out pyright

This commit is contained in:
Dima Gerasimov 2024-08-27 21:02:39 +01:00
parent b1fe23b8d0
commit dee0b128ca
7 changed files with 12 additions and 14 deletions

View file

@ -133,8 +133,8 @@ def test_classproperty() -> None:
return 'hello'
res = C.prop
assert res == 'hello'
assert_type(res, str)
assert res == 'hello'
# hmm, this doesn't really work with mypy well..

View file

@ -2,7 +2,7 @@
Helpers for hpi doctor/stats functionality.
'''
import collections
import collections.abc
import importlib
import inspect
import typing

View file

@ -25,7 +25,7 @@ def is_not_hpi_module(module: str) -> Optional[str]:
'''
None if a module, otherwise returns reason
'''
import importlib
import importlib.util
path: Optional[str] = None
try:

View file

@ -275,20 +275,18 @@ def test_check_if_hashable() -> None:
x1: List[int] = [1, 2]
r1 = check_if_hashable(x1)
# tgype: ignore[comparison-overlap] # object should be unchanged
assert r1 is x1
assert_type(r1, Iterable[int])
assert r1 is x1
x2: Iterator[Union[int, str]] = iter((123, 'aba'))
r2 = check_if_hashable(x2)
assert list(r2) == [123, 'aba']
assert_type(r2, Iterable[Union[int, str]])
assert list(r2) == [123, 'aba']
x3: Tuple[object, ...] = (789, 'aba')
r3 = check_if_hashable(x3)
# ttype: ignore[comparison-overlap] # object should be unchanged
assert r3 is x3
assert_type(r3, Iterable[object])
assert r3 is x3 # object should be unchanged
x4: List[Set[int]] = [{1, 2, 3}, {4, 5, 6}]
with pytest.raises(Exception):