Skip to content

Commit 5c32631

Browse files
fix parse_config for asyncssh>=2.19.0 (#58)
Also deprecate the function and raise a warning when it is used. Co-authored-by: Sailesh <[email protected]>
1 parent 47d78ac commit 5c32631

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

sshfs/config.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import getpass
2+
import warnings
23
from contextlib import suppress
34
from pathlib import Path
45

6+
import asyncssh
57
from asyncssh.config import SSHClientConfig
68

79
SSH_CONFIG = Path("~", ".ssh", "config").expanduser()
@@ -10,20 +12,40 @@
1012
def parse_config(
1113
*, host, user=(), port=(), local_user=None, config_files=None
1214
):
15+
warnings.warn(
16+
"parse_config is deprecated and will be removed in the future.",
17+
DeprecationWarning,
18+
)
19+
1320
if config_files is None:
1421
config_files = [SSH_CONFIG]
1522

1623
if local_user is None:
17-
with suppress(KeyError):
24+
with suppress(KeyError, OSError):
1825
local_user = getpass.getuser()
1926

2027
last_config = None
2128
reload = False
2229

30+
version = tuple(map(int, asyncssh.__version__.split(".")))
31+
if version < (2, 19, 0):
32+
return SSHClientConfig.load(
33+
last_config,
34+
config_files,
35+
reload,
36+
local_user,
37+
user,
38+
host,
39+
port,
40+
)
41+
canonical = False
42+
final = False
2343
return SSHClientConfig.load(
2444
last_config,
2545
config_files,
2646
reload,
47+
canonical,
48+
final,
2749
local_user,
2850
user,
2951
host,

tests/test_config.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,4 @@ def test_config_expansions(tmpdir):
4545
ProxyCommand ssh proxy nc %h %p
4646
""",
4747
)
48-
49-
assert (
50-
config.get("ProxyCommand") == "ssh proxy nc base.dvc.org 222".split()
51-
)
48+
assert config.get("ProxyCommand") == "ssh proxy nc base.dvc.org 222"

0 commit comments

Comments
 (0)