uranusjr commented on code in PR #30495: URL: https://github.com/apache/airflow/pull/30495#discussion_r1159423802
########## airflow/utils/file.py: ########## @@ -371,3 +371,14 @@ def might_contain_dag_via_default_heuristic(file_path: str, zip_file: zipfile.Zi content = dag_file.read() content = content.lower() return all(s in content for s in (b"dag", b"airflow")) + + +def get_airflow_modules_in(file_path: str) -> Generator[str]: + """Returns a list of the airflow modules that are imported in the given file""" + with open(file_path, "rb") as dag_file: + content = dag_file.read() + lines = content.splitlines() + for line in lines: + if line.startswith(b"from airflow.") or line.startswith(b"import airflow."): + module_name = line.split(b" ")[1] + yield module_name.decode() Review Comment: A lot of possible improvements but they can be introduced later. -- 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. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org