How to type hint an overloaded decorator that may wrap sync or async function

Also worth taking note of PEP 742, which recently replaced PEP 724.

In fact, PEP 742 has been making a lot of recent progress. Just last week the TC voted in favor of PEP 742, and experimental support for PEP 742 has already been merged into typing_extensions (v4.10.0+), pyright (v1.1.351+), and mypy (next release, 1.10.0?).

As long as you’re OK with using experimental typing features, it may be possible to make this work using TypeIs and mypy master.

1 Like