Skip to content

Commit 9e2f033

Browse files
Allow is_instance_of for types that only implement PyTypeCheck (#5146)
1 parent 11c9863 commit 9e2f033

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

newsfragments/5146.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow `is_instance_of` for types that only implement `PyTypeCheck`

src/types/any.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ pub trait PyAnyMethods<'py>: crate::sealed::Sealed {
904904
///
905905
/// This is equivalent to the Python expression `isinstance(self, T)`,
906906
/// if the type `T` is known at compile time.
907-
fn is_instance_of<T: PyTypeInfo>(&self) -> bool;
907+
fn is_instance_of<T: PyTypeCheck>(&self) -> bool;
908908

909909
/// Checks whether this object is an instance of exactly type `T`.
910910
///
@@ -1558,8 +1558,8 @@ impl<'py> PyAnyMethods<'py> for Bound<'py, PyAny> {
15581558
}
15591559

15601560
#[inline]
1561-
fn is_instance_of<T: PyTypeInfo>(&self) -> bool {
1562-
T::is_type_of(self)
1561+
fn is_instance_of<T: PyTypeCheck>(&self) -> bool {
1562+
T::type_check(self)
15631563
}
15641564

15651565
#[inline]

0 commit comments

Comments
 (0)