Repository navigation
mkdir(): allow a missing SFTP channel (#394) - #436
Closed
danielagbo888-png wants to merge 2 commits into
Closed
danielagbo888-png wants to merge 2 commits into
danielagbo888-png wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #436 +/- ##
==========================================
- Coverage 99.47% 99.41% -0.06%
==========================================
Files 18 18
Lines 1708 1713 +5
==========================================
+ Hits 1699 1703 +4
- Misses 9 10 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
Closing this as a duplicate of #432, which I missed before opening it — it covers the same change and also drops the channel requirement from sftp_put/sftp_get. No reason to make you compare two diffs for the same thing. |
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.
mkdir()now creates its own SFTP channel when one isn't supplied, as raised in #394.copy_file()already doessftp = self._make_sftp() if sftp is None else sftp.mkdir()didn't, so creating a directory meant reaching into_make_sftp()yourself first.Both call forms work now:
They're told apart by
directory is None and isinstance(sftp, str)— an SFTP channel is never a string, so the two can't be confused.I kept the parameter order rather than moving to
mkdir(directory, sftp=None), so no existing positional caller breaks. That's the one decision I'd understand pushback on: the clean signature reads better and would matchcopy_file(), but it needs a breaking-change note, and #394 already suggested doing that "in a later version". Happy to flip it here if you'd rather take the break now.Tests —
tests/test_native_single_mkdir.py, 4 tests, no SSH server needed (client built withobject.__new__, channel faked):mkdir('/tmp/remote-dir')creates the channel once and makes each missing parent.mkdir(sftp, path)does not create a channelmkdir()raisesTypeErrorinstead of anAttributeErroronNoneOn
mastertwo of them fail withTypeError: mkdir() missing 1 required positional argument: 'directory'. With the patch all four pass, and the non-server suite (25 tests) still passes.Only the native client is touched: the
ssh/libssh client has no SFTP methods, so there was nothing to mirror there.pathlib.Patharguments were already unsupported before this change (the body calls.split('/')), so this doesn't regress them — worth a separate issue if you wantos.PathLikesupport.Integration coverage —
ci/integration_tests/libssh2_clients/test_single_client.py::test_sftp_mkdir_without_channelcallsmkdir(path)against the repo's embedded sshd and asserts the parent chain exists on disk. It fails onmasterwith the sameTypeError, so the new form is covered both with and without a channel in hand.CI on this PR: CircleCI 3.8 / 3.11 / 3.12 / 3.13, Hound and codecov all green, and codecov reports every modified line covered.