This is an automated email from the ASF dual-hosted git repository.
kamilbregula 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 fc8d38d improve typing for openfaas provider (#9883)
fc8d38d is described below
commit fc8d38d5f22a59db08d845de55e65e818f3be4dc
Author: morrme <[email protected]>
AuthorDate: Mon Jul 20 08:49:13 2020 -0500
improve typing for openfaas provider (#9883)
Co-authored-by: Kamil BreguĊa <[email protected]>
---
airflow/providers/openfaas/hooks/openfaas.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/airflow/providers/openfaas/hooks/openfaas.py
b/airflow/providers/openfaas/hooks/openfaas.py
index 8eaf70d..c3eb87d 100644
--- a/airflow/providers/openfaas/hooks/openfaas.py
+++ b/airflow/providers/openfaas/hooks/openfaas.py
@@ -16,6 +16,8 @@
# specific language governing permissions and limitations
# under the License.
+from typing import Any, Dict
+
import requests
from airflow.exceptions import AirflowException
@@ -29,7 +31,7 @@ class OpenFaasHook(BaseHook):
Interact with OpenFaaS to query, deploy, invoke and update function
:param function_name: Name of the function, Defaults to None
- :type query: str
+ :type function_name: str
:param conn_id: openfaas connection to use, Defaults to open_faas_default
for example host : http://openfaas.faas.com, Conn Type : Http
:type conn_id: str
@@ -42,8 +44,8 @@ class OpenFaasHook(BaseHook):
def __init__(self,
function_name=None,
- conn_id='open_faas_default',
- *args, **kwargs):
+ conn_id: str = 'open_faas_default',
+ *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.function_name = function_name
self.conn_id = conn_id
@@ -52,7 +54,7 @@ class OpenFaasHook(BaseHook):
conn = self.get_connection(self.conn_id)
return conn
- def deploy_function(self, overwrite_function_if_exist, body):
+ def deploy_function(self, overwrite_function_if_exist: bool, body:
Dict[str, Any]) -> None:
"""
Deploy OpenFaaS function
"""
@@ -70,7 +72,7 @@ class OpenFaasHook(BaseHook):
else:
self.log.info("Function deployed %s", self.function_name)
- def invoke_async_function(self, body):
+ def invoke_async_function(self, body: Dict[str, Any]) -> None:
"""
Invoking function
"""
@@ -83,7 +85,7 @@ class OpenFaasHook(BaseHook):
self.log.error("Response status %d", response.status_code)
raise AirflowException('failed to invoke function')
- def update_function(self, body):
+ def update_function(self, body: Dict[str, Any]) -> None:
"""
Update OpenFaaS function
"""
@@ -97,7 +99,7 @@ class OpenFaasHook(BaseHook):
else:
self.log.info("Function was updated")
- def does_function_exist(self):
+ def does_function_exist(self) -> bool:
"""
Whether OpenFaaS function exists or not
"""