Create a generic python class from a rust struct. #3155
Unanswered
hoel-bagard
asked this question in
Questions
Replies: 1 comment
-
For anyone having the same issue, what I did is add the from _mypackage import MyClass
from typing import Generic, TypeVar
T = TypeVar("T", int, str)
class MyClass(MyClass, Generic[T]):
pass |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm wondering if there is a way to make a generic python class using PyO3. I don't want to modify the rust code's behavior, my goal is to be able to write better type stubs for my package.
I would like to write stubs like this one:
Which would allow a type checker to check cases like this one:
(My rust code is a struct with an
Enum
field, and some python functions do not have the same signature depending on the variant of the enum)Beta Was this translation helpful? Give feedback.
All reactions