Skip to content
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

Error when dynamically constructing classes from reflected metaclass #7086

Closed
PeterJCLaw opened this issue Jun 27, 2019 · 1 comment
Closed

Comments

@PeterJCLaw
Copy link
Contributor

In the following code, the presence of the last line (the call to foo_meta) causes mypy to emit an error without a line number and which cannot be ignored.

class FooMeta(type):
    pass
class Foo(metaclass=FooMeta):
    pass

foo_meta = type(Foo)
reveal_type(foo_meta)  # shows: Revealed type is 'Type[def () -> foo.Foo]'

foo_meta("Bar", (Foo,), {})

The error is:

foo.py: error: Unsupported type Type["Type[Foo]"]

I would expect that even if mypy were unable to determine the types here I would be able to ignore the error with a suitably placed # type: ignore (instead I get a warning about an unused ignore). Ideally the usage wouldn't error at all though.

Python: 3.5.2
mypy: 0.701 (verified still an issue under 0.711, the latest at the time of writing)

@ilevkivskyi
Copy link
Member

I think this actually a duplicate of #4300

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

No branches or pull requests

2 participants