Skip to content

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.

2 participants