We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following code:
from typing import Iterator from pytypes import TypeChecker def f() -> Iterator[str]: yield 'abc' with TypeChecker(): x = tuple(c for c in f()) print("OK")
fails as follows:
$ python3 Test.py Traceback (most recent call last): File "Test.py", line 9, in <module> x = tuple(c for c in f()) File "Test.py", line 9, in <genexpr> x = tuple(c for c in f()) File "Test.py", line 6, in f yield 'abc' pytypes.exceptions.ReturnTypeError: __main__.f returned incompatible type: Expected: Iterator[str] Received: str
Also a simple call to f(), not wrapped in generator expression and tuple, fails in a slightly different manner:
f()
tuple
$ python3 Test.py Exception ignored in: <generator object f at 0x7fe74e4b7db0> Traceback (most recent call last): File "Test.py", line 5, in f def f() -> Iterator[str]: File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2580, in __call__ _check_caller_type(True, None, arg, caller_level=self._caller_level_shift+1) File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2431, in _check_caller_type prop_getter, force_exception=True) File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/typechecker.py", line 718, in _checkfuncresult _raise_typecheck_error(msg, True, check_val, tpch, resSig, func) File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2336, in _raise_typecheck_error raise pytypes.ReturnTypeError(msg) pytypes.exceptions.ReturnTypeError: __main__.f returned incompatible type: Expected: Iterator[str] Received: NoneType OK
Similar stacks occur if Iterator[str] is replaced with Generator[str, None, None].
Iterator[str]
Generator[str, None, None]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The following code:
fails as follows:
Also a simple call to
f()
, not wrapped in generator expression andtuple
, fails in a slightly different manner:Similar stacks occur if
Iterator[str]
is replaced withGenerator[str, None, None]
.The text was updated successfully, but these errors were encountered: