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

How to add attributes to Callable? #3882

Closed
vitawasalreadytaken opened this issue Aug 27, 2017 · 1 comment
Closed

How to add attributes to Callable? #3882

vitawasalreadytaken opened this issue Aug 27, 2017 · 1 comment

Comments

@vitawasalreadytaken
Copy link
Contributor

I have a simple decorator that just sets an attribute on a function and returns it. The closest I got to checking this is creating a subclass of Callable and adding the attribute to it:

from typing import Callable, cast

class RemoteCallable(Callable):
	rpc_name: str = None

def remote(f: Callable) -> RemoteCallable:
	''' Decorator marking a function as callable via the RPC system. '''
	f = cast(RemoteCallable, f)
	f.rpc_name = f.__name__
	return f

However, this fails with rpc.py:3: error: Invalid base class. What can I do?

@JelleZijlstra
Copy link
Member

This isn't currently supported yet, but @ilevkivskyi came up with an elegant approach recently so we can support it; see #2087. Closing as a duplicate of that issue.

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

No branches or pull requests

2 participants