Implement noconvert for std::filesystem::path#5889
Open
gentlegiantJGC wants to merge 4 commits intopybind:masterfrom
Open
Implement noconvert for std::filesystem::path#5889gentlegiantJGC wants to merge 4 commits intopybind:masterfrom
gentlegiantJGC wants to merge 4 commits intopybind:masterfrom
Conversation
The current cast implementation for std::filesystem::path is to always cast. If the argument is marked as noconvert() it will convert regardless. This change rejects the argument if convert is false and the argument is not an instance of pathlib.Path.
Collaborator
|
We should be checking for |
Contributor
Author
I am confused about the intended implementation of Should a If that is the case the current implementation is correct but the type hint is incorrect. Currently the type hints look like this m.def("path_convert", [](std::filesystem::path) { }, py::arg("path"));
m.def("path_noconvert", [](std::filesystem::path) { }, py::arg("path").noconvert());def path_convert(path: os.PathLike | str | bytes) -> None: ...
def path_noconvert(path: pathlib.Path) -> None: ...I was modifying the type caster to match the type hint thinking that the type hint was correct. Should the noconvert type hint be If that is the case I think |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The current cast implementation for std::filesystem::path is to always cast.
If the argument is marked as noconvert() it will convert regardless.
This change rejects the argument if convert is false and the argument is not an instance of pathlib.Path.
Suggested changelog entry: