-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
modules as protocols doesn't type-check against the protocol #13771
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
Comments
Cc. @ilevkivskyi |
This feature was not yet released. But actually the fact that there is no error means there (without this feature there should be always an error, even if it matches protocol) is an unrelated bug (and I even guess I know where). |
It however affects the feature as well, so I am going to look at it. |
oh my bad, I thought that it was in the release, oops -- I will double-check on latest then |
@ilevkivskyi I can repro on master. It looks like the issue is that |
That was one of my "innovations". Maybe it was a bad idea. Previous discussion in: |
Certainly wasn't an unreasonable thing to do. I think it's probably something we live with and work around in mypy. If you're interested in my (somewhat off-topic) thoughts on that change:
|
TBH I don't like the (I will take a look at the PR still to have a back up plan) |
That's an interesting idea. One downside I can see is that the result of collections = __import__("collections")
reveal_type(collections) # types._AnyModuleType ???
|
I am going to merge #13778 to speed up things (and since I don't have strongly either way). |
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
I was really excited to see #13513 merge but trying it out seems like it doesn't actually type-check things
here's a small example
I expect this to error because the
f
insidet
returnsint
but the protocol specifies it should returnstr
.additionally, I think I should also be able to write something like this, but it currently errors for an unrelated reason (even when the module matches the protocol):
Your Environment
mypy main.py
mypy.ini
(and other config files): n/aThe text was updated successfully, but these errors were encountered: