2121import warnings
2222from typing import TYPE_CHECKING , Any
2323
24+ import attr
25+
2426from airflow .exceptions import AirflowProviderDeprecationWarning
2527from airflow .models import BaseOperatorLink , XCom
2628from airflow .providers .google .cloud .links .base import BASE_LINK , BaseGoogleLink
@@ -42,6 +44,7 @@ def __getattr__(name: str) -> Any:
4244 " Please use DATAPROC_JOB_LINK instead"
4345 ),
4446 AirflowProviderDeprecationWarning ,
47+ stacklevel = 2 ,
4548 )
4649 return DATAPROC_JOB_LINK
4750 raise AttributeError (f"module { __name__ } has no attribute { name } " )
@@ -68,18 +71,15 @@ def __getattr__(name: str) -> Any:
6871)
6972
7073
74+ @attr .s (auto_attribs = True )
7175class DataprocLink (BaseOperatorLink ):
7276 """
7377 Helper class for constructing Dataproc resource link.
7478
7579 .. warning::
76- This link is deprecated .
80+ This link is pending to deprecate .
7781 """
7882
79- warnings .warn (
80- "This DataprocLink is deprecated." ,
81- AirflowProviderDeprecationWarning ,
82- )
8383 name = "Dataproc resource"
8484 key = "conf"
8585
@@ -116,7 +116,17 @@ def get_link(
116116 else ""
117117 )
118118
119+ def __attrs_post_init__ (self ):
120+ # This link is still used into the selected operators
121+ # - airflow.providers.google.cloud.operators.dataproc.DataprocScaleClusterOperator
122+ # - airflow.providers.google.cloud.operators.dataproc.DataprocJobBaseOperator
123+ # - airflow.providers.google.cloud.operators.dataproc.DataprocSubmitPigJobOperator
124+ # As soon as we remove reference to this link we might deprecate it by add warning message
125+ # with `stacklevel=3` below in this method.
126+ ...
119127
128+
129+ @attr .s (auto_attribs = True )
120130class DataprocListLink (BaseOperatorLink ):
121131 """
122132 Helper class for constructing list of Dataproc resources link.
@@ -125,7 +135,6 @@ class DataprocListLink(BaseOperatorLink):
125135 This link is deprecated.
126136 """
127137
128- warnings .warn ("This DataprocListLink is deprecated." , AirflowProviderDeprecationWarning )
129138 name = "Dataproc resources"
130139 key = "list_conf"
131140
@@ -159,6 +168,13 @@ def get_link(
159168 else ""
160169 )
161170
171+ def __attrs_post_init__ (self ):
172+ warnings .warn (
173+ "This DataprocListLink is deprecated." ,
174+ AirflowProviderDeprecationWarning ,
175+ stacklevel = 3 ,
176+ )
177+
162178
163179class DataprocClusterLink (BaseGoogleLink ):
164180 """Helper class for constructing Dataproc Cluster Link."""
0 commit comments