Skip to content

Use object as the fallback for various Callable types #3831

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

Closed
JukkaL opened this issue Aug 15, 2017 · 2 comments
Closed

Use object as the fallback for various Callable types #3831

JukkaL opened this issue Aug 15, 2017 · 2 comments

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Aug 15, 2017

If a class with __call__ can be a subtype of Callable (#3132 implements this behavior), the fallback of Callable types should probably be object. For function objects defined using def, it's perhaps still fine to use a different callback.

Additionally, callable protocol members should probably all have a object as the fallback, even those defined using def. A concrete subtype of a protocol could implement a method using an instance of a user-defined class with __call__, which could effectively have an arbitrary fallback type.

More discussion: #3132 (comment)

cc @ilevkivskyi

@ilevkivskyi
Copy link
Member

It looks like we could use fallbacks to relatively easily allow subclassing Callable (same as for NamedTuples and TypedDicts), see discussion in #2087. Note that this already correctly works at runtime.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Jan 29, 2020

I'm not convinced that this is worth the extra complexity.

@JukkaL JukkaL closed this as completed Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants