Closed p0llard closed 6 months ago
I'm not familar enough with PyO3 to know whether it would allow implicit conversions of any Iterable[int]; this page implies it needs to be a list, but the error message (which comes from PyO3) implies it might accept collections.abc.Sequence or something similar.
I carried out a quick experiment, and it seems that arbitrary collections.abc.Sequence
subclasses are indeed accepted, and work as expected.
Because our library is written in Rust we had to manually add the type stubs.
Not only did I get bfs_search
wrong, I also got dfs_search
and dijkstra_search
incorrectly as well. I think we can release a fix for this for sure in 0.15 and maybe it warrants a 0.14.2 release.
In the meantime you will need to ignore the annotation if you are using mypy/pyright/etc
Hi @IvanIsCoding. I would like to work on this issue, if possible can you assign it to me
Hi @IvanIsCoding. I would like to work on this issue, if possible can you assign it to me
Sounds good. Check https://github.com/Qiskit/rustworkx/blob/main/CONTRIBUTING.md. You will need to generate a release note + change the rustworkx.pyi + init.pyi files. If you include universal and type-specific functions for Dijkstra, BFS, and DFS they will be 9 in total
I will try to target release the fix for this with the fix for https://github.com/Qiskit/rustworkx/issues/1117 in 0.14.2
https://github.com/Qiskit/rustworkx/blob/6e37baf11c0bda266ca6e95999d9d749f0d6204e/src/traversal/mod.rs#L424-L429 shows
source
is anOptional<Vec<usize>>
but the Python type stubs show the binding taking a singleint
: https://github.com/Qiskit/rustworkx/blob/6e37baf11c0bda266ca6e95999d9d749f0d6204e/rustworkx/__init__.pyi#L552-L556The examples in the documentation (correctly) show singleton lists being passed: https://github.com/Qiskit/rustworkx/blob/6e37baf11c0bda266ca6e95999d9d749f0d6204e/rustworkx/__init__.py#L1533
If a single
int
is passed, thenis raised.
I'm not familar enough with PyO3 to know whether it would allow implicit conversions of any
Iterable[int]
; this page implies it needs to be alist
, but the error message (which comes from PyO3) implies it might acceptcollections.abc.Sequence
or something similar.