-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
TypeError when calling isinstance on a TrameApp decorated object #594
Comments
That is a good issue but I'm not sure how to solve that... maybe by doing the following from trame.decorators import TrameApp
class TestApp:
server = None
t = TrameApp()(TestApp)()
print(isinstance(t, TestApp)) |
That is a solution, although fairly hard to follow in practice |
yes, I agree and I'm not sure how to solve that. |
I asked Chat and it suggested creating a wrapper class with the decorator. class TrameApp:
def __call__(self, klass):
class WrappedClass(klass):
...
return WrappedClass It could work, but then it could introduce other problems with type checking since |
We might be able to re-design the class a little bit to support this. I might look into it later this week. |
I just found another issue that the function wrapper may be causing. Not quite sure why this is occuring though: from trame.decorators import TrameApp
@TrameApp()
class TestApp:
server = None
@TrameApp()
class TestApp2(TestApp):
server = None
t = TestApp()
t2 = TestApp2()
If this a separate problem, I can make a new issue. I will look into it more tomorrow probably. |
I think this is related because the decorated TestApp is actually a function and not a class which prevent you from inheriting it. |
Hey @psavery, I just wanted to check in on the status of this? |
Describe the bug
Using
isinstance
on a@TrameApp()
decorated class throws aTypeError
.To Reproduce
Steps to reproduce the behavior:
Code
Expected behavior
I would assume
isinstance
would work. This is not a critical problem though as we have other workarounds.The problem is that the
@TrameApp()
decorator returns a function that instantiates the class instead of returning a class itself. TheTypeError
is thrown because we are checking if a object is an instance of a function, which is not possible to check.Maybe
isinstance
would never be a good way to handle this, either way it would be very useful to have a good way of checking the type of our app's instances.Platform:
OS:
The text was updated successfully, but these errors were encountered: