Skip to content

Commit

Permalink
fix parse_config for asyncssh>=2.19.0
Browse files Browse the repository at this point in the history
Also deprecate the function and raise a warning when it is used.

Co-authored-by: Sailesh <[email protected]>
  • Loading branch information
99-NinetyNine authored and skshetry committed Feb 6, 2025
1 parent 47d78ac commit 1d45f0b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
24 changes: 23 additions & 1 deletion sshfs/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import getpass
import warnings
from contextlib import suppress
from pathlib import Path

import asyncssh
from asyncssh.config import SSHClientConfig

SSH_CONFIG = Path("~", ".ssh", "config").expanduser()
Expand All @@ -10,20 +12,40 @@
def parse_config(
*, host, user=(), port=(), local_user=None, config_files=None
):
warnings.warn(
"parse_config is deprecated and will be removed in the future.",
DeprecationWarning,
)

if config_files is None:
config_files = [SSH_CONFIG]

if local_user is None:
with suppress(KeyError):
with suppress(KeyError, OSError):
local_user = getpass.getuser()

last_config = None
reload = False

version = tuple(map(int, asyncssh.__version__.split(".")))
if version < (2, 19, 0):
return SSHClientConfig.load(
last_config,
config_files,
reload,
local_user,
user,
host,
port,
)
canonical = False
final = False
return SSHClientConfig.load(
last_config,
config_files,
reload,
canonical,
final,
local_user,
user,
host,
Expand Down
5 changes: 1 addition & 4 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,4 @@ def test_config_expansions(tmpdir):
ProxyCommand ssh proxy nc %h %p
""",
)

assert (
config.get("ProxyCommand") == "ssh proxy nc base.dvc.org 222".split()
)
assert config.get("ProxyCommand") == "ssh proxy nc base.dvc.org 222"

0 comments on commit 1d45f0b

Please sign in to comment.