Skip to content

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

Closed
@petergaultney

Description

@petergaultney
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions