uranusjr commented on code in PR #22854:
URL: https://github.com/apache/airflow/pull/22854#discussion_r878979381


##########
airflow/www/utils.py:
##########
@@ -483,20 +483,37 @@ def pygment_html_render(s, lexer=lexers.TextLexer):
     return highlight(s, lexer(), HtmlFormatter(linenos=True))
 
 
-def render(obj, lexer):
+def render(obj: Any, lexer, handler=None):
     """Render a given Python object with a given Pygments lexer"""
-    out = ""
+
     if isinstance(obj, str):
-        out = Markup(pygment_html_render(obj, lexer))
-    elif isinstance(obj, (tuple, list)):
+        return Markup(pygment_html_render(obj, lexer))
+
+    if isinstance(obj, (tuple, list)):
+        out = ""

Review Comment:
   Instead of repeatedly call `+` on strings, it may be a better idea to turn 
this into a generator, and do a `join` instead.
   
   ```python
   def _render_parts(obj, lexer, handler):
       ...
       yield Markup(...)
       ...
   
   def render(obj, lexer, handler):
       return "".join(_render_parts(obj, lexer, handler))
   ```



-- 
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