Replies: 1 comment
-
Implicit conversions are a somewhat advanced feature. The Python typing infrastructure AFAIK doesn't support a way of specifying them except for copy-pasting unions all possible conversions all over the place (which is unfortunate). nanobind's stubgen currently doesn't provide a way of performing this transformation automatically in generated stubs, and it would be complicated to realize such a feature. My suggestion would be that you either override signatures via |
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.
-
Assume you have a class A with an implicit constructor from double and a class B with a constructor from A.
The binding code looks like this:
In python we can write
b = B(1.234)
However, the generated pyi file has only a stub for the constructor of B from A.
As a consequence, type checking fails.
I know I can explicitly add a signature:
Is there a better way to handle this?
Beta Was this translation helpful? Give feedback.
All reactions