You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/10/09 07:37:17 UTC

[airflow] branch master updated: Bugfix: Error in SSHOperator when command is None (#11361)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 27e637f  Bugfix: Error in SSHOperator when command is None (#11361)
27e637f is described below

commit 27e637fbe3f17737e898774ff151448f4f0aa129
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Fri Oct 9 08:35:39 2020 +0100

    Bugfix: Error in SSHOperator when command is None (#11361)
    
    closes https://github.com/apache/airflow/issues/10656
---
 airflow/providers/ssh/operators/ssh.py    | 2 +-
 tests/providers/ssh/operators/test_ssh.py | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/airflow/providers/ssh/operators/ssh.py b/airflow/providers/ssh/operators/ssh.py
index 8bf5e8a..333e0fb 100644
--- a/airflow/providers/ssh/operators/ssh.py
+++ b/airflow/providers/ssh/operators/ssh.py
@@ -78,7 +78,7 @@ class SSHOperator(BaseOperator):
         self.command = command
         self.timeout = timeout
         self.environment = environment
-        self.get_pty = self.command.startswith('sudo') or get_pty  # type: ignore[union-attr]
+        self.get_pty = (self.command.startswith('sudo') or get_pty) if self.command else get_pty
 
     def execute(self, context) -> Union[bytes, str, bool]:
         try:
diff --git a/tests/providers/ssh/operators/test_ssh.py b/tests/providers/ssh/operators/test_ssh.py
index 23794b2..41302b1 100644
--- a/tests/providers/ssh/operators/test_ssh.py
+++ b/tests/providers/ssh/operators/test_ssh.py
@@ -191,6 +191,7 @@ class TestSSHOperator(unittest.TestCase):
             (COMMAND, True, True),
             (COMMAND_WITH_SUDO, False, True),
             (COMMAND_WITH_SUDO, True, True),
+            (None, True, True),
         ]
     )
     def test_get_pyt_set_correctly(self, command, get_pty_in, get_pty_out):