Skip to content

mypy master fails in typeshed CI #3301

New issue

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

Closed
JelleZijlstra opened this issue May 2, 2017 · 8 comments
Closed

mypy master fails in typeshed CI #3301

JelleZijlstra opened this issue May 2, 2017 · 8 comments
Labels

Comments

@JelleZijlstra
Copy link
Member

  File "/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/mypy/nodes.py", line 2275, in SymbolTableNode
    def type(self) -> Optional['mypy.types.Type']:
  File "/opt/python/3.5.2/lib/python3.5/typing.py", line 649, in __getitem__
    return Union[arg, type(None)]
  File "/opt/python/3.5.2/lib/python3.5/typing.py", line 552, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "/opt/python/3.5.2/lib/python3.5/typing.py", line 512, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/opt/python/3.5.2/lib/python3.5/typing.py", line 512, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/opt/python/3.5.2/lib/python3.5/typing.py", line 190, in __subclasscheck__
    self._eval_type(globalns, localns)
  File "/opt/python/3.5.2/lib/python3.5/typing.py", line 177, in _eval_type
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
AttributeError: module 'mypy' has no attribute 'types'

From https://travis-ci.org/python/typeshed/jobs/227972982

Presumably we need to use 'Optional[mypy.types.Type]' instead? Not sure how this wasn't caught by any of mypy's own tests.

@gvanrossum
Copy link
Member

Just traded this back to Ivan's recent Optional cleanup. More to follow.

@ilevkivskyi
Copy link
Member

This is definitely due to Optional['mypy.types.Type']. But this (eager union simplification using forward reference evaluation) was fixed several month ago in typing. Do we need to support also older versions of typing? If yes, then I can make a small PR replacing this with 'Optional[mypy.types.Type]'.

@gvanrossum
Copy link
Member

Yes, we need to support whatever typing.py is shipped with Python 3.5.1. #ilevkivskyi how soon can you have this fixed? Otherwise I'll just revert #3292 (the culprit).

gvanrossum pushed a commit that referenced this issue May 2, 2017
This reverts commit 058a8a6.

The reason is that it crashes when run with Python 3.5.

Fixes #3301 (with a sledgehammer :-).
@ilevkivskyi
Copy link
Member

I can do this within 30 minutes.

@ilevkivskyi
Copy link
Member

@JelleZijlstra @gvanrossum Here is PR #3303 that should fix this. Could you please verify that the crash is fixed?

Btw, maybe we need to add tests with different versions of typing to mypy CI? It is quite easy to miss something like this in future.

@JelleZijlstra
Copy link
Member Author

Thanks Ivan!

As for preventing this in the future, the bug apparently doesn't appear with mypy 3.5.1, because that's what mypy's CI uses. Typeshed's CI uses the default Travis version of 3.5, which is 3.5.2.

@gvanrossum
Copy link
Member

the bug apparently doesn't appear with mypy 3.5.1, because that's what mypy's CI uses

Incorrect. The repro I have also uses 3.5.1. As I said above, I suspect that the bug depends on import order within mypy itself and our Travis runs use runtests.py which imports some other modules so the import order problem is avoided.

@ilevkivskyi
Copy link
Member

I just checked when exactly Union was fixed in typing: the problem exists in both 3.5.1 and 3.5.2, but is fixed in 3.5.3 and in 3.6.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants