Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix checking of self when accessing a non-method callable attribute (take 2) #4016
Fix #3223. Minimal examples:
from typing import Callable class X: f: Callable[[object], None] X().f # E: Invalid method type
class X: @property def g(self: object): pass X().g # E: Invalid method type
The problem is that for non-methods the check performed on access to
Take 2 of #3227, but without the reverse-operator part
Thanks for the PR! Note that this is not a full review, just some quick notes.
Can you update the PR message to describe the problem that this PR fixes, with an example? Currently I need to look up the issue to understand what is going on. Another nit is that the title of the PR doesn't communicate the purpose of this PR very well, but maybe it's hard to summarize it better.
I checked that this doesn't cause any issues with internal Dropbox codebases.
Thanks for fixing this -- it now looks cleaner (plus it also works better!). This concludes my review.
Some of the self type related code is still kind of hard to understand -- I added some ideas below for how to clarify things. If some of the suggested changes would require many additional changes (such as renaming
original_type to something else) it's probably better to do that as a separate PR.
@JukkaL I will only be available for a couple of hours from now, so I won't be able to respond to further comments in time, unless ~30 hours from now will be good enough. As I understand it, the behavior is OK, and I hope it will be possible to resolve further issues in docstrings and comments even after the branch is cut.