You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to bind some classes with optional fields. I need to support mutable semantics (rv_policy::reference_internal across the board). So I'm implementing bindings like this:
TypeError: (): incompatible function arguments. The following argument types are supported:
1. (self, arg: int | None, /) -> None
Invoked with types: Foo, NoneType
I'm not sure why it is confusing NoneType with None. This is reproducible in 1.9 and 2.1
I've tried putting nb::for_setter(nb::arg().none()) instead of without for_setter. I have two workarounds:
Pass a nb::handle instead of int32_t*. The disadvantage is losing nice error messages and adding error handling code.
Pass optional<int32_t> and use the optional type_caster. The disadvantage is I'd rather not bring that type_caster into scope, because it's so important I don't accidentally use it for non-primitive cases.
I'm curious if this is actually a bug
Reproducible example code
No response
The text was updated successfully, but these errors were encountered:
Problem description
I'm trying to bind some classes with optional fields. I need to support mutable semantics (
rv_policy::reference_internal
across the board). So I'm implementing bindings like this:example python code:
the last line fails with this error:
I'm not sure why it is confusing
NoneType
withNone
. This is reproducible in 1.9 and 2.1I've tried putting
nb::for_setter(nb::arg().none())
instead of withoutfor_setter
. I have two workarounds:nb::handle
instead ofint32_t*
. The disadvantage is losing nice error messages and adding error handling code.optional<int32_t>
and use the optional type_caster. The disadvantage is I'd rather not bring that type_caster into scope, because it's so important I don't accidentally use it for non-primitive cases.I'm curious if this is actually a bug
Reproducible example code
No response
The text was updated successfully, but these errors were encountered: