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
What version (or hash if on master) of pybind11 are you using?
2.12.0
Problem description
If I have some class inheriting from collections.abc, it would not implicitly cast to corresponding C++ types. Example code shows a reproduction.
This probably makes most sense as nowadays a lot of Python libraries use Mapping/Set as an abstract type instead of dictionary.
Example code with set follows
Reproducible example code
Python class
from collections.abc import MutableSet
class CaselessSet(MutableSet[str]):
# Using https://stackoverflow.com/a/27531275 as the implementation
# ... implementation not written for brevity
C++ `mymod`
m.def("set_size", [](set<string>& s) {
return s.size();
});
`mymod.pyi`:
from collections.abc import Set as AbstractSet
def set_size(set: AbstractSet[str])
usage:
s = CaselessSet('a', 'B')
mymod.set_size(s)
Is this a regression? Put the last known working version here if it is.
Not a regression
The text was updated successfully, but these errors were encountered:
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
2.12.0
Problem description
If I have some class inheriting from
collections.abc
, it would not implicitly cast to corresponding C++ types. Example code shows a reproduction.This probably makes most sense as nowadays a lot of Python libraries use
Mapping/Set
as an abstract type instead of dictionary.Example code with set follows
Reproducible example code
Is this a regression? Put the last known working version here if it is.
Not a regression
The text was updated successfully, but these errors were encountered: