Skip to content

Commit 07a13bb

Browse files
authored
Change ComputeSSH to throw provider import error instead paramiko (#23035)
The paramiko import should be done after ssh provider to properly detect it as an optional Google Provider feature. Part of: #23033
1 parent 79ab71e commit 07a13bb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

airflow/providers/google/cloud/hooks/compute_ssh.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
from io import StringIO
2121
from typing import Any, Dict, Optional
2222

23-
import paramiko
24-
2523
if sys.version_info >= (3, 8):
2624
from functools import cached_property
2725
else:
@@ -34,6 +32,11 @@
3432
from airflow.providers.google.cloud.hooks.os_login import OSLoginHook
3533
from airflow.providers.ssh.hooks.ssh import SSHHook
3634

35+
# Paramiko should be imported after airflow.providers.ssh. Then the import will fail with
36+
# cannot import "airflow.providers.ssh" and will be correctly discovered as optional feature
37+
# TODO:(potiuk) We should add test harness detecting such cases shortly
38+
import paramiko # isort:skip
39+
3740

3841
class _GCloudAuthorizedSSHClient(paramiko.SSHClient):
3942
"""SSH Client that maintains the context for gcloud authorization during the connection"""

0 commit comments

Comments
 (0)