Skip to content

Commit c719970

Browse files
99-NinetyNineskshetry
authored andcommitted
fix parse_config for asyncssh>=2.19.0
Also deprecate the function and raise a warning when it is used. Co-authored-by: Sailesh <58628378+99-NinetyNine@users.noreply.github.com>
1 parent 47d78ac commit c719970

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

sshfs/config.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,49 @@
11
import getpass
22
from contextlib import suppress
33
from pathlib import Path
4+
import warnings
5+
import asyncssh
46

57
from asyncssh.config import SSHClientConfig
68

79
SSH_CONFIG = Path("~", ".ssh", "config").expanduser()
810

911

10-
def parse_config(
11-
*, host, user=(), port=(), local_user=None, config_files=None
12-
):
12+
def parse_config(*, host, user=(), port=(), local_user=None, config_files=None):
13+
warnings.warn(
14+
"parse_config is deprecated and will be removed in the future.",
15+
DeprecationWarning,
16+
)
17+
1318
if config_files is None:
1419
config_files = [SSH_CONFIG]
1520

1621
if local_user is None:
17-
with suppress(KeyError):
22+
with suppress(KeyError, OSError):
1823
local_user = getpass.getuser()
1924

2025
last_config = None
2126
reload = False
2227

28+
version = tuple(map(int, asyncssh.__version__.split(".")))
29+
if version < (2, 19, 0):
30+
return SSHClientConfig.load(
31+
last_config,
32+
config_files,
33+
reload,
34+
local_user,
35+
user,
36+
host,
37+
port,
38+
)
39+
canonical = False
40+
final = False
2341
return SSHClientConfig.load(
2442
last_config,
2543
config_files,
2644
reload,
45+
canonical,
46+
final,
2747
local_user,
2848
user,
2949
host,

0 commit comments

Comments
 (0)