File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
task-sdk/src/airflow/sdk/definitions Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,18 @@ def _convert_doc_md(doc_md: str | None) -> str | None:
185
185
return fh .read ()
186
186
except FileNotFoundError :
187
187
return doc_md
188
+ return doc_md
189
+
188
190
191
+ def _clean_doc_md (doc_md : str ) -> str :
192
+ # alternative to using math.inf, the linter doesn't like inf being a float
193
+ strip_count = len (doc_md )
194
+
195
+ for line in doc_md .split ("\n " ):
196
+ if line != "" :
197
+ strip_count = min (strip_count , len (line ) - len (line .lstrip ()))
198
+ if strip_count > 0 :
199
+ doc_md = "\n " .join ([line [strip_count :] for line in doc_md .split ("\n " )])
189
200
return doc_md
190
201
191
202
@@ -1120,8 +1131,7 @@ def factory(*args, **kwargs):
1120
1131
with DAG (dag_id , ** decorator_kwargs ) as dag_obj :
1121
1132
# Set DAG documentation from function documentation if it exists and doc_md is not set.
1122
1133
if f .__doc__ and not dag_obj .doc_md :
1123
- dag_obj .doc_md = f .__doc__
1124
-
1134
+ dag_obj .doc_md = _clean_doc_md (f .__doc__ )
1125
1135
# Generate DAGParam for each function arg/kwarg and replace it for calling the function.
1126
1136
# All args/kwargs for function will be DAGParam object and replaced on execution time.
1127
1137
f_kwargs = {}
You can’t perform that action at this time.
0 commit comments