Skip to content

Allow sftp=None in native SSHClient.mkdir, sftp_put and sftp_get - #432

Open
DanShinde wants to merge 1 commit into
ParallelSSH:masterfrom
DanShinde:sftp-none-mkdir-put-get
Open

DanShinde wants to merge 1 commit into
ParallelSSH:masterfrom
DanShinde:sftp-none-mkdir-put-get

Conversation

@DanShinde

Copy link
Copy Markdown

Resolves #394.

SSHClient.copy_file already creates an SFTP channel when sftp is None, but mkdir, sftp_put and sftp_get required one, so users had to call the private _make_sftp() first.

This PR makes those three methods (native client) accept None for sftp and create a new channel in that case. The signatures are unchanged, so existing callers are not affected, and client.mkdir(None, '/some/dir') now works. I kept sftp positional rather than giving it a default, since it comes before directory and moving it would be a breaking change; happy to change that if you prefer a keyword default in a future major version.

Also adds a docstring to sftp_get, a Changelog entry under 2.17.0, and two integration tests (test_sftp_mkdir_no_sftp, test_sftp_put_get_no_sftp) that fail on master and pass with the change.

Tested locally against the embedded OpenSSH server: the sftp/copy/mkdir tests in ci/integration_tests/libssh2_clients/test_single_client.py pass (the existing test_sftp_openfh_exc fails only because I ran as root, same on master). flake8 is clean.

A new SFTP channel is created when sftp is None, as copy_file already
does. Resolves ParallelSSH#394.
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.41%. Comparing base (6bfe5f9) to head (3d81492).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #432      +/-   ##
==========================================
- Coverage   99.47%   99.41%   -0.06%     
==========================================
  Files          18       18              
  Lines        1708     1711       +3     
==========================================
+ Hits         1699     1701       +2     
- Misses          9       10       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sftp=None support for creating SFTP channel to SSHClient.mkdir()

1 participant