Skip to content

stubgen fails with "TypeError: tuple object expected" running against cattr package #6639

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
petergaultney opened this issue Apr 6, 2019 · 3 comments

Comments

@petergaultney
Copy link

  • Are you reporting a bug, or opening a feature request?

Bug

  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.

No code, but I'm trying to generate stubs for cattrs, which lives here: https://github.com/Tinche/cattrs

The command I'm using, on MyPy 0.700, is stubgen -p cattr. MyPy does manage to find the package. (for instance, stubgen -p cattrs gives the expected message Failed to import cattrs; skipping it)

I am running this inside a clean virtualenv.

  • What is the actual behavior/output?
Traceback (most recent call last):
  File "/Users/peter/.local/share/virtualenvs/testpy-XO9km9Nb/bin/stubgen", line 10, in <module>
    sys.exit(main())
  File "mypy/stubgen.py", line 1191, in main
  File "mypy/stubgen.py", line 1075, in generate_stubs
  File "mypy/stubgen.py", line 899, in collect_build_targets
  File "mypy/stubgen.py", line 930, in find_module_paths_using_imports
TypeError: tuple object expected
  • What is the behavior/output you expect?

I would expect the out directory to be created with some stubs.

  • What are the versions of mypy and Python you are using?

Python 3.7.2, MyPy 0.700

  • Do you see the same issue after installing mypy from Git master?
    I get an entirely different error! Fascinating.
Failed to import cattr.vendor.python2.typing; skipping it
Failed to import cattr.vendor.python3.typing; skipping it
Failed to import cattr.vendor.typing; skipping it
Critical error during semantic analysis: /Users/peter/.local/share/virtualenvs/testpy-XO9km9Nb/lib/python3.7/site-packages/cattr/converters.py:149: error: misplaced type annotation

I already expected that the error might lie within cattrs itself, but obviously the 0.700 error message was not helping me at all. This is a lot more useful. I suggest that this issue be closed once 0.710 is released and still manifests this improved error behavior, and then this issue may help others who are running into similar issues on older versions of MyPy.

@petergaultney petergaultney changed the title stubgen fails with TypeError: tuple object expected for cattr package stubgen fails with "TypeError: tuple object expected" running against cattr package Apr 6, 2019
@ilevkivskyi
Copy link
Member

This looks like a mypyc issue. You likely don't see the error on master because you use the interpreted version. There were no changes to stubgen between 0.700 and now.

Most likely @msullivan knows the answer.

@msullivan
Copy link
Collaborator

Yeah it is an interaction with mypyc. Error message is bad too, so I filed mypyc/mypyc#552.

I'll put up a PR right now. This is a very bad regression but also it is only stubgen so I dunno if it is worth a point release

msullivan added a commit that referenced this issue Apr 6, 2019
find_module_path_and_all_py3 promises to return __all__ as a List, but
__all__ could be a tuple or something. Make sure to convert it.

Fixes #6639.
msullivan added a commit that referenced this issue Apr 6, 2019
find_module_path_and_all_py3 promises to return __all__ as a List, but
__all__ could be a tuple or something. Make sure to convert it.

Fixes #6639.
msullivan added a commit that referenced this issue Apr 6, 2019
find_module_path_and_all_py3 promises to return __all__ as a List, but
__all__ could be a tuple or something. Make sure to convert it.

Fixes #6639.
@ilevkivskyi
Copy link
Member

I don't think we need a point release (unless there will be more reports of this issue).

msullivan added a commit that referenced this issue Apr 6, 2019
find_module_path_and_all_py3 promises to return __all__ as a List, but
__all__ could be a tuple or something. Make sure to convert it.

Fixes #6639.
msullivan added a commit that referenced this issue Apr 15, 2019
find_module_path_and_all_py3 promises to return __all__ as a List, but
__all__ could be a tuple or something. Make sure to convert it.

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

No branches or pull requests

3 participants