omkar-foss commented on code in PR #65423:
URL: https://github.com/apache/airflow/pull/65423#discussion_r3213686420


##########
scripts/ci/prek/common_prek_utils.py:
##########
@@ -79,6 +79,50 @@ def temporary_tsc_project(
     yield temp_tsconfig_path
 
 
+def is_valid_python(contents: str) -> bool:
+    """
+    Checks if contents is valid python code or not.
+    args:
+        contents (str): Code contents.
+    returns: True if valid python code, False otherwise.
+    """
+    try:
+        compile(contents, "<string>", "exec")
+        return True
+    except SyntaxError:
+        return False
+
+
+@contextmanager
+def temporary_python_file(dir_path: Path, contents: str) -> 
Generator[_TemporaryFileWrapper, None, None]:

Review Comment:
   Done



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to