Skip to content

Commit e812dae

Browse files
Update config.py, naive solution
1 parent da82e76 commit e812dae

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

sshfs/config.py

+33-27
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
11
import getpass
22
from contextlib import suppress
3-
from pathlib import Path, PurePath
4-
from typing import Sequence, Union
3+
from pathlib import Path
4+
import asyncssh
5+
56
from asyncssh.config import SSHClientConfig
67

78
SSH_CONFIG = Path("~", ".ssh", "config").expanduser()
8-
FilePath = Union[str, PurePath]
9-
def parse_config(
10-
*, host, user=(), port=(), local_user=None, config_files=None
11-
):
9+
10+
11+
def parse_config(*, host, user=(), port=(), local_user=None, config_files=None):
1212
if config_files is None:
1313
config_files = [SSH_CONFIG]
1414

1515
if local_user is None:
16-
with suppress(KeyError):
16+
with suppress(OSError): # Use OSError as getuser() might raise this.
1717
local_user = getpass.getuser()
1818

1919
last_config = None
2020
reload = False
21-
config = SSHClientConfig(
22-
last_config =last_config,
23-
reload = reload,
24-
canonical = False,
25-
final=False,
26-
local_user = local_user,
27-
user = user,
28-
host = host,
29-
port = port,
30-
)
31-
32-
if config_files:
33-
if isinstance(config_files, (str, PurePath)):
34-
paths: Sequence[FilePath] = [config_files]
35-
else:
36-
paths = config_files
3721

38-
for path in paths:
39-
config.parse(Path(path))
40-
config.loaded = True
41-
return config
22+
# Check asyncssh version
23+
version = tuple(map(int, asyncssh.__version__.split(".")))
24+
if version <= (2, 18, 0): # Compare version properly
25+
return SSHClientConfig.load(
26+
last_config,
27+
config_files,
28+
reload,
29+
local_user,
30+
user,
31+
host,
32+
port,
33+
)
34+
else:
35+
canonical = False # Fixed typo
36+
final = False # Fixed typo
37+
return SSHClientConfig.load(
38+
last_config,
39+
config_files,
40+
reload,
41+
canonical, # Use correct parameter
42+
final, # Use correct parameter
43+
local_user,
44+
user,
45+
host,
46+
port,
47+
)

0 commit comments

Comments
 (0)