Skip to content

MyPy doesn't understand types.ModuleType #1498

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
wittekm opened this issue May 6, 2016 · 1 comment · Fixed by #3107
Closed

MyPy doesn't understand types.ModuleType #1498

wittekm opened this issue May 6, 2016 · 1 comment · Fixed by #3107
Labels
bug mypy got something wrong priority-0-high

Comments

@wittekm
Copy link
Contributor

wittekm commented May 6, 2016

I tried doing # type: (module) -> str and MyPy was okay with it, but our linter was not. Some discussion in our Slack channel:

Guido:
From types import ModuleType?
Oh wow. Please file a bug. Mypy uses builtins.module but that doesn't exist so can't be used at runtime; types.ModuleType exists but mypy doesn't understand it.

David Fisher:
oh interesting
we have a "class module" entry in builtins
with the comment # TODO not defined in builtins!

@gvanrossum gvanrossum added this to the 0.4.x milestone May 6, 2016
@gvanrossum
Copy link
Member

Yeah, so apparently when mypy sees a variable that's a module (as opposed to just an import statement) it gives it the type builtins.module even though that doesn't exist. The actual type of module objects is types.ModuleType. This would probably be easy to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-0-high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants