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 c719970
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions sshfs/config.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
import getpass
from contextlib import suppress
from pathlib import Path
import warnings
import asyncssh

from asyncssh.config import SSHClientConfig

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


def parse_config(
*, host, user=(), port=(), local_user=None, config_files=None
):
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

0 comments on commit c719970

Please sign in to comment.