Uh oh!
There was an error while loading. Please reload this page.
Minor updates to protocol semantics - #3996
Conversation
gvanrossum
commented
Sep 26, 2017
@JukkaL Can you review this? @ilevkivskyi What changed so that reveal_type() of |
ilevkivskyi
commented
Sep 26, 2017
This: This fix will anyway happen in #3952, but without it this test (expectedly) crashed. |
JukkaL
left a comment
There was a problem hiding this comment.
Thanks for the PR! Looks good, just a few minor comments.
| class P(Protocol): | ||
| pass | ||
| x: P = None |
There was a problem hiding this comment.
Also test that None is compatible with a non-empty protocol when not using strict optional checking.
| ' instance and class checks', e) | ||
| if (isinstance(e.callee, RefExpr) and len(e.args) == 2 and | ||
| e.callee.fullname == 'builtins.issubclass'): | ||
| for expr in mypy.checker.flatten(e.args[1]): |
There was a problem hiding this comment.
Move the body to a separate method, as this function is already quite long. Maybe also move the body of the above if statement (from line 269) to a separate method. You could also move the if statement to be nested under the above if statement (line 267). You'd only need the check if e.callee.fullname == 'builtins.subclass' which would simplify things slightly.
JukkaL
commented
Sep 28, 2017
Can you also fix the merge conflict? |
ilevkivskyi
commented
Sep 28, 2017
Thanks! I addressed CR and fixed the conflict. |
This reverts commit b3ca169.
This updates protocol semantic according to the discussion in python/typing#464:
Noneshould be considered a subtype of an empty protocolmethod = Nonerule should apply only to callable protocol membersissublcass()is prohibited for protocols with non-method members.Fixes#3906
Fixes#3938
Fixes#3939