You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the trio_typing.plugin is enabled with mypy 1.7, it can cause false positive errors (even when trio is not even in use) related to Mypy's new type inference which was enabled by default in python/mypy#16345 for mypy 1.7.
main.py:24: note: Revealed type is "def () -> __main__.C"
main.py:25: note: Revealed type is "def [_T_co] (make_client: def () -> _T_co`173) -> contextlib._AsyncGeneratorContextManager[_T_co`173]"
main.py:26: note: Revealed type is "contextlib._AsyncGeneratorContextManager[__main__.C]"
main.py:25: note: Revealed type is "def () -> __main__.C"
main.py:26: note: Revealed type is "def [T] (make_client: def () -> T`-1) -> contextlib._AsyncGeneratorContextManager[T`-1]"
main.py:27: note: Revealed type is "contextlib._AsyncGeneratorContextManager[__main__.C]"
When the new type inference is used with a config file that enables the plugin
Since trio 0.23 we've added inline types, and once mypy releases support for TypeVarTuples (which should be in the next release afaict) I think we can fully deprecate the plugin.
It would maybe be good to do a final release of trio-typing which is compatible with mypy 1.7, but I haven't touched the plugin previously myself so am not especially tempted to try and debug this thing in particular.
Is there any particular functionality you're after the plugin provides that's not provided by using trio 0.23 and current mypy?
When the
trio_typing.plugin
is enabled with mypy 1.7, it can cause false positive errors (even when trio is not even in use) related to Mypy's new type inference which was enabled by default inpython/mypy#16345 for mypy 1.7.
When linting async functions that take generic callables, the new type inference appears to automatically infer the variance of typevars. For example:
https://mypy-play.net/?mypy=latest&python=3.11&gist=73fc0a0b94a3f2410080c0482df7ecab
Outputs:
But if you add
# mypy: old-type-inference
to the top: https://mypy-play.net/?mypy=latest&python=3.11&gist=be6764bbead8f238976dd1be12d8d7e8 then it outputs:When the new type inference is used with a config file that enables the plugin
then an error is reported for this code:
The text was updated successfully, but these errors were encountered: