Skip to content

Commit

Permalink
describe mypy-related limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
Anvil committed Dec 16, 2023
1 parent 0a1024e commit 8434a9c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,28 @@ tedious. The `signature-mutators` directive will globally disable the
signature-checking for `aioretry()` and `retry()` calls, so this can be easier
depending of your own usage of kaioretry.)

## Mypy and functions generated by kaioretry.aioretry

[Mypy](https://github.com/python/mypy) may incorrectly infer the type of an
aioretry-decorated function as `def (*Any, **Any) -> Any` *if* the original
function:

1. is a coroutine _and_
2. has a returned type hinted as `Any` and/or if parameters are hinted as `Any`.

If the original function is fully annotated as non-`Any`, the resulting
decorated function annotations should be correctly inferred (according to
[kaioretry test](/Anvil/kaioretry/main/test/static_analysis)).

It is unclear to me right now, if the `kaioretry.aioretry` function type hints
are incorrect or if it is an issue with either mypy or cpython. Or both. Or
all 3. Go figure.

Any information on that matter would be greatly appreciated. I've spent weeks
trying to track down this issue. And while walking down this path has allowed
me to fix some other (rather unrelated) type-hinting boo-boos from my part,
this very specific issue is still puzzling me.

# Feedback welcome.

Always.

0 comments on commit 8434a9c

Please sign in to comment.