From e2d8897a45a022469d903e21436d658507eb2ce3 Mon Sep 17 00:00:00 2001 From: Fuxino Date: Thu, 8 Oct 2026 17:47:02 +0200 Subject: [PATCH] Fix crash on Python < 3.14 when paramiko is not installed The return annotation of _ssh_connect referenced paramiko, which Python < 3.14 evaluates at class definition, raising NameError when paramiko (an optional dependency) is missing. Postpone evaluation of annotations, and mark the return type as Optional. --- simple_backup/simple_backup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/simple_backup/simple_backup.py b/simple_backup/simple_backup.py index 977f951..9b1a9ed 100755 --- a/simple_backup/simple_backup.py +++ b/simple_backup/simple_backup.py @@ -11,6 +11,9 @@ Classes: Backup """ +# Avoid evaluating annotations at definition time, as they reference optional modules (paramiko) +from __future__ import annotations + # Import libraries import traceback import sys @@ -327,7 +330,7 @@ class Backup: except IndexError: logger.info('No previous backups available') - def _ssh_connect(self, homedir: str = '') -> paramiko.client.SSHClient: + def _ssh_connect(self, homedir: str = '') -> Optional[paramiko.client.SSHClient]: try: ssh = paramiko.SSHClient() except NameError: