Page MenuHomeSoftware Heritage
Paste P731

pre-commit mypy unhappy about PagedResult[TResult, str] alias
ActivePublic

Authored by ardumont on Jul 29 2020, 8:00 AM.
pre-commit mypy:
```
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1
swh/storage/interface.py:37: error: Type variable "swh.core.api.classes.TResult" is unbound
swh/storage/interface.py:37: note: (Hint: Use "Generic[TResult]" or "Protocol[TResult]" base class to bind "TResult" inside a class)
swh/storage/interface.py:37: note: (Hint: Use "TResult" in function signature to bind "TResult" inside a function)
swh/storage/interface.py:37: error: Incompatible types in assignment (expression has type "Type[PagedResult[Any, Any]]", variable has type "PagedResult[TResult?, str]")
swh/storage/interface.py:809: error: Variable "swh.storage.interface.PagedResult" is not valid as a type
swh/storage/interface.py:809: note: See https://mypy.readthedocs.io/en/latest/common_issues.html#variables-vs-type-aliases
swh/storage/in_memory.py:869: error: Variable "swh.storage.interface.PagedResult" is not valid as a type
swh/storage/in_memory.py:869: note: See https://mypy.readthedocs.io/en/latest/common_issues.html#variables-vs-type-aliases
swh/storage/in_memory.py:903: error: "PagedResult[TResult?, str]" not callable
swh/storage/cassandra/storage.py:851: error: Variable "swh.storage.interface.PagedResult" is not valid as a type
swh/storage/cassandra/storage.py:851: note: See https://mypy.readthedocs.io/en/latest/common_issues.html#variables-vs-type-aliases
swh/storage/cassandra/storage.py:877: error: "PagedResult[TResult?, str]" not callable
swh/storage/storage.py:890: error: Variable "swh.storage.interface.PagedResult" is not valid as a type
swh/storage/storage.py:890: note: See https://mypy.readthedocs.io/en/latest/common_issues.html#variables-vs-type-aliases
swh/storage/storage.py:926: error: "PagedResult[TResult?, str]" not callable
Found 9 errors in 4 files (checked 68 source files)
```
mypy and tests through tox is fine though (`-m 'not cassandra'` here but that does not change a thing for the type thingy):
```
=================================================================================== 625 passed, 156 deselected, 1 xfailed, 17 warnings in 113.25s (0:01:53) ===================================================================================
___________________________________________________________________________________________________________________ summary ___________________________________________________________________________________________________________________
black: commands succeeded
flake8: commands succeeded
mypy: commands succeeded
py3: commands succeeded
congratulations :)
```