Skip to content

Mypy 0.710 broke support for inline weak import comments #7024

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
AdiRishi opened this issue Jun 20, 2019 · 5 comments
Closed

Mypy 0.710 broke support for inline weak import comments #7024

AdiRishi opened this issue Jun 20, 2019 · 5 comments

Comments

@AdiRishi
Copy link

Are you reporting a bug, or opening a feature request?
I'm reporting a breaking change in mypy 0.710

Please insert below the code you are checking with mypy
The following import at the top of a file no longer works

# mypy: weak=import

What is the actual behavior/output?
<path_to_file>:1: error: Unrecognized option: weak = import

What is the behavior/output you expect?
It is expected that mypy allows weak imports in the file, or at the very least doesn't raise an error.

What are the versions of mypy and Python you are using?
Python version: 3.7
mypy version: 0.710
mypy-extensions version: 0.4.1
typed-ast version: 1.4.0

What are the mypy flags you are using? (For example --strict-optional)
The exact command we are running is
mypy --ignore-missing-imports --disallow-untyped-defs --strict-optional

I have yet to find which exact version of mypy had this breaking change.
I just thought I'd make this issue, and see if you are aware/have a recommended fix for this.

I appreciate any help you provide and I'm happy to provide further details if necessary.

@msullivan
Copy link
Collaborator

What does # mypy: weak=import mean in this context? It doesn't mean anything to mypy and I don't think it ever has. Is there some other tool that cares about it?

Starting with version 0.710, # mypy: comments at the toplevel are understood by mypy to be configuration options.

If there is a particularly well established use of # mypy: comments already, then we might need to rethink this, but otherwise we're probably not fixing this.

@JelleZijlstra
Copy link
Member

JelleZijlstra commented Jun 20, 2019

Apparently this used to do something before mypy 0.4.5: http://mypy-lang.blogspot.com/2016/10/mypy-045-released.html (see under "Deprecations and Removals"). Mypy has been ignoring these comments for years though.

@AdiRishi
Copy link
Author

As far as I can tell, # mypy: weak=import has been a comment that did things in the past.
You can see other people recommending it in past comments - #971 (comment)

Your explanation on why this is now an error makes sense, weak=import is indeed not a configuration option in mypy.

Unfortunately I couldn't tell you what weak=import does, it's part of some old code we have.
I'm happy if you don't support it going forward, just through I'd bring this up in an issue since this will cause existing builds to fail which use the option

@AdiRishi
Copy link
Author

Happy to close this issue with the resolution that this is a won't fix

@msullivan
Copy link
Collaborator

Today I learn!

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

3 participants