HENNGE / aiodynamo

Asynchronous, fast, pythonic DynamoDB Client
https://aiodynamo.readthedocs.io/
Other
73 stars 21 forks source link

Incompatible argument type issues after version 22.2 #119

Closed MarkusSintonen closed 2 years ago

MarkusSintonen commented 2 years ago

Mypy has started to give errors such as Client" has incompatible type "HTTPX"; expected "FixedCallable[Request, Awaitable[Response]] after version 22.2. This happens when trying to use aiodynamo as documented here https://github.com/HENNGE/aiodynamo#with-httpx and running mypy (eg with default settings in v0.931).

This also happens in the repository it self when running mypy over the unit test code. Same errors happen eg in https://github.com/HENNGE/aiodynamo/blob/master/tests/integration/conftest.py#L142. As an idea it would be good to run mypy over the unit test code here instead of just running it over src as defined in the mypy.ini. It would avoid the type breakage:

aiodynamo % poetry run mypy tests
... some errors omitted ...
tests/unit/test_errors.py:26: error: Argument 1 to "Client" has incompatible type "AIOHTTP"; expected "FixedCallable[Request, Awaitable[Response]]"
tests/unit/test_errors.py:51: error: Argument 1 to "Client" has incompatible type "AIOHTTP"; expected "FixedCallable[Request, Awaitable[Response]]"
tests/unit/test_client.py:43: error: Argument 1 to "Client" has incompatible type "Callable[[Request], Coroutine[Any, Any, Response]]"; expected "FixedCallable[Request, Awaitable[Response]]"
tests/integration/conftest.py:114: error: Incompatible return value type (got "Callable[[Throughput], Coroutine[Any, Any, str]]", expected "Callable[[Optional[Throughput]], Awaitable[str]]")
tests/integration/conftest.py:142: error: Argument 1 to "Client" has incompatible type "HTTPX"; expected "FixedCallable[Request, Awaitable[Response]]"
tests/integration/conftest.py:160: error: Argument 1 to "Client" has incompatible type "HTTPX"; expected "FixedCallable[Request, Awaitable[Response]]"
Found 52 errors in 8 files (checked 11 source files)

Thank you all for the awesome library!

ojii commented 2 years ago

This also happens in the repository it self when running mypy over the unit test code. Same errors happen eg in https://github.com/HENNGE/aiodynamo/blob/master/tests/integration/conftest.py#L142. As an idea it would be good to run mypy over the unit test code here instead of just running it over src as defined in the mypy.ini. It would avoid the type breakage:

I even had mypy set up to run on CI to catch such issues... Thank you for your report, I'll look into it.

By the way: make sure to upgrade to 22.2.1 since 22.2 has a rather nasty bug with regards to error handling.

ojii commented 2 years ago

@MarkusSintonen I'd appreciate it if you could review #120