PyType.is_subclass
does not work with two dynamic PyType
s
#1984
Labels
PyType.is_subclass
does not work with two dynamic PyType
s
#1984
Hello! During Pants's migration to PyO3, I'm stuck on how to get
&PyType.is_subclass()
working.This is what I would like to do:
If I understand correctly, this is not possible because the API is
is_subclass<T>(&self)
, and it doesn't seem possible to say this due to how Generics work in Rust:For now, I'm thinking I can work around this by writing our own
unsafe
implementation, but I'd love to be able to contribute a more flexible API to PyO3. I'm thinkingis_subclass(&self, T: ToPyObject) -> bool
.What do you think? How would we handle deprecations? (Note that rust-cpython calls it
is_subtype_of
, maybe that's an option)Also I'm curious what you think about it returning
bool
instead ofPyResult<bool>
?The text was updated successfully, but these errors were encountered: