TobKed commented on a change in pull request #5980: [AIRFLOW-5129] Add typehint
to GCP DLP hook
URL: https://github.com/apache/airflow/pull/5980#discussion_r319810718
##########
File path: airflow/gcp/hooks/dlp.py
##########
@@ -53,28 +66,34 @@ class CloudDLPHook(GoogleCloudBaseHook):
:type delegate_to: str
"""
- def __init__(self,
- gcp_conn_id="google_cloud_default",
- delegate_to=None):
+ def __init__(self, gcp_conn_id="google_cloud_default", delegate_to=None):
super().__init__(gcp_conn_id, delegate_to)
self._client = None
- def get_conn(self):
+ def get_conn(self) -> DlpServiceClient:
"""
Provides a client for interacting with the Cloud DLP API.
:return: GCP Cloud DLP API Client
:rtype: google.cloud.dlp_v2.DlpServiceClient
"""
if not self._client:
- self._client =
DlpServiceClient(credentials=self._get_credentials(),
client_info=self.client_info)
+ self._client = DlpServiceClient(
+ credentials=self._get_credentials(),
+ client_info=self.client_info,
+ )
return self._client
@GoogleCloudBaseHook.catch_http_exception
@GoogleCloudBaseHook.fallback_to_default_project_id
def cancel_dlp_job(
- self, dlp_job_id, project_id=None, retry=None, timeout=None,
metadata=None
- ):
+ self,
+ dlp_job_id: str,
+ project_id: str = None,
Review comment:
Could you add `Optional` to arguments where default is `None`? There is a
discussion about using `Optional` here [[AIRFLOW-5359] Update type annotations
in
BaseOperator](https://github.com/apache/airflow/pull/5965#discussion_r319617606).
> Following discussion in python/typing#275, there is a consensus that it is
better to require optional types to be made explicit. This PR changes the
wording of PEP 484 to allow, but not require, type checkers to treat a None
default as implicitly making an argument Optional.
Additional reference: https://github.com/python/peps/pull/689
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services