Skip to content
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

Addresses review of #11630 #11638

Merged
merged 4 commits into from Dec 1, 2021
Merged

Addresses review of #11630 #11638

merged 4 commits into from Dec 1, 2021

Conversation

sobolevn
Copy link
Member

Refs #11630

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but I think is_operator needs to be True... See #11637

@sobolevn
Copy link
Member Author

@hauntsaninja with is_operator=True this condition does not work: https://github.com/python/mypy/blob/master/mypy/checkmember.py#L385-L386

I think that I might be confused by how __getattr__ works with __call__ here 🤔

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Nov 29, 2021

I might be confused too :-) See #11630 (comment) for what I'm looking at

@sobolevn
Copy link
Member Author

TIL that __getattr__ is not called when we use this code:

class D:
    def __getattr__(self, attr: str) -> DCall:
        if attr == "__call__":
            return lambda *a, **kw: print(a, kw)
        raise AttributeError

D().__call__('a')  # called
D()('a')  # not called

So, my assumption of allowing classes with __getattr__ to be treated as callables - is not correct. I will update this PR appropriately.

Thanks!

@hauntsaninja hauntsaninja reopened this Dec 1, 2021
@hauntsaninja hauntsaninja merged commit 3027cd6 into python:master Dec 1, 2021
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants