Navigation Menu

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

NamedTuple subclasses are not considered callable even when they have a __call__ method #4360

Closed
msullivan opened this issue Dec 13, 2017 · 1 comment
Labels

Comments

@msullivan
Copy link
Collaborator

from typing import Tuple, NamedTuple

Thing = NamedTuple('Thing', [('s', str), ('n', int)])

class CallableTuple(Thing):
    def __call__(self) -> str:
        return self.s + str(self.n)

o = CallableTuple('hello ', 12)
print(o())

produces the message
error: "CallableTuple" not callable

@gvanrossum gvanrossum changed the title Tuple subclasses are not considered callable even when they have a __call__ method NamedTuple subclasses are not considered callable even when they have a __call__ method Dec 14, 2017
@ilevkivskyi ilevkivskyi added bug mypy got something wrong priority-1-normal labels Dec 14, 2017
@ilevkivskyi
Copy link
Member

This one is easy, just add another elif for TupleType in checkexpr.check_call that just calls check_call on tuple fallback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants