-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer DefaultPlugin to handle functions
This will allow to correctly infer types for contextmanagers and open function when mypy-zope plugin is enabled. Fixes #35
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from collections import Iterator | ||
from contextlib import contextmanager | ||
from typing import TypeVar, Generic | ||
|
||
_T = TypeVar("_T") | ||
|
||
|
||
class A(Generic[_T]): | ||
pass | ||
|
||
@contextmanager | ||
def m(x: _T) -> Iterator[A[_T]]: | ||
... | ||
|
||
|
||
with m(7) as x: | ||
reveal_type(x) | ||
print(x) | ||
|
||
|
||
""" | ||
<output> | ||
contextmanager.py:17: note: Revealed type is '__main__.A*[builtins.int*]' | ||
</output> | ||
""" |