Skip to content

Commit

Permalink
Fix static checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksYermak authored and potiuk committed Apr 25, 2022
1 parent 22ea28f commit d6094e5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions airflow/providers/google/cloud/hooks/kubernetes_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(
delegate_to=delegate_to,
impersonation_chain=impersonation_chain,
)
self._client = None
self._client = None # type: Optional[ClusterManagerClient]
self.location = location

def get_cluster_manager_client(self) -> ClusterManagerClient:
Expand Down Expand Up @@ -151,7 +151,7 @@ def delete_cluster(
name: str,
project_id: str = PROVIDE_PROJECT_ID,
retry: Union[Retry, _MethodDefault] = DEFAULT,
timeout: _MethodDefault = DEFAULT,
timeout: Optional[float] = None,
) -> Optional[str]:
"""
Deletes the cluster, including the Kubernetes endpoint and all
Expand Down Expand Up @@ -188,10 +188,10 @@ def delete_cluster(
@GoogleBaseHook.fallback_to_default_project_id
def create_cluster(
self,
cluster: Union[Dict, Cluster],
cluster: Union[Dict, Cluster, None],
project_id: str = PROVIDE_PROJECT_ID,
retry: Union[Retry, _MethodDefault] = DEFAULT,
timeout: _MethodDefault = DEFAULT,
timeout: Optional[float] = None,
) -> str:
"""
Creates a cluster, consisting of the specified number and type of Google Compute
Expand All @@ -217,15 +217,18 @@ def create_cluster(
elif not isinstance(cluster, Cluster):
raise AirflowException("cluster is not instance of Cluster proto or python dict")

self._append_label(cluster, 'airflow-version', 'v' + version.version)
self._append_label(cluster, 'airflow-version', 'v' + version.version) # type: ignore

self.log.info(
"Creating (project_id=%s, location=%s, cluster_name=%s)", project_id, self.location, cluster.name
"Creating (project_id=%s, location=%s, cluster_name=%s)",
project_id,
self.location,
cluster.name, # type: ignore
)
try:
resource = self.get_cluster_manager_client().create_cluster(
parent=f'projects/{project_id}/locations/{self.location}',
cluster=cluster,
cluster=cluster, # type: ignore
retry=retry,
timeout=timeout,
)
Expand All @@ -234,15 +237,15 @@ def create_cluster(
return resource.target_link
except AlreadyExists as error:
self.log.info('Assuming Success: %s', error.message)
return self.get_cluster(name=cluster.name, project_id=project_id)
return self.get_cluster(name=cluster.name, project_id=project_id) # type: ignore

@GoogleBaseHook.fallback_to_default_project_id
def get_cluster(
self,
name: str,
project_id: str = PROVIDE_PROJECT_ID,
retry: Union[Retry, _MethodDefault] = DEFAULT,
timeout: _MethodDefault = DEFAULT,
timeout: Optional[float] = None,
) -> Cluster:
"""
Gets details of specified cluster
Expand Down

0 comments on commit d6094e5

Please sign in to comment.