-
Notifications
You must be signed in to change notification settings - Fork 373
Accept pathlib.Path object in Context.cd #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On one hand, I'm not sure how we could go about this without actually depending on |
I just stumbled upon this while investigating a somewhat misleading error message:
I used a Path object instead of a string as argument for So… how about just casting the argument to a string at the start of the method? No need to depend on |
I had the exact same problem. I wonder if there is anything stopping the PR from being merged? |
wondering about this as well. would be a great feature to have. |
The pull request #583 seems to address this problem, any reason to not accept it? |
|
My PR is fixing the same issue -> #681 |
Edit: Whoops, I should have looked at the PRs first. Yeah, no need to actually add it as a dependency since casting to |
I think it's OK to just convert the path to string for Invoke because it runs the commands on the compatible OS but I am not sure if it doesn't break Fabric. Fabric uses the path on remote server and doing |
Unless I'm mistaken, you could simply use |
Looking forward to this functionality! We use |
I just hit this snag. It would be nice to see it progress. |
@miso-belica Arguably, as you and @rspeed touch on, that situation requires forethought on the part of the user. At the very least it would need to be covered under fabric/fabric#1752. For the purposes of what Invoke can or should do at its level, in the usual "work well for Invoke-only users, and try not to actively get in the way of client libraries like Fabric" approach, I think the solution in the linked PRs (and #607) is probably fine: expect that the given values can be safely cast to strings if they aren't already. Backwards compatible, works with Path objects of most stripes, works with other stuff too. Insofar as it's not perfect for Fabric, it's still an improvement for anyone using eg PosixPath (since right now those users are manually calling str()) and is no worse otherwise. So Fabric can take its time figuring out that abovelinked issue. I'll be merging #607 shortly, after tweaking the test suite to more explicitly test that contract instead of Path objects specifically. |
Test didn't need to use Path objects; only needs to test the contract being defined.
Allow the path parameter to be a
pathlib.Path
instance as well as a string parameter. As a convenience aspathlib.Path
are used more and more for path handling. Thanks.The text was updated successfully, but these errors were encountered: