Skip to content

Commit 4db14c0

Browse files
committed
refactor: remove monkeypatch for DataFrame._repr_html_ and associated logic
1 parent 4069d80 commit 4db14c0

1 file changed

Lines changed: 0 additions & 31 deletions

File tree

python/datafusion/__init__.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -126,34 +126,3 @@ def str_lit(value):
126126
def lit(value) -> Expr:
127127
"""Create a literal expression."""
128128
return Expr.literal(value)
129-
130-
131-
# Apply monkeypatch for DataFrame._repr_html_ to properly use our HTML formatter
132-
def _patch_dataframe_repr_html():
133-
"""Apply patch to DataFrame._repr_html_ to use our HTML formatter."""
134-
try:
135-
from datafusion.dataframe import DataFrame
136-
from datafusion.html_formatter import get_formatter
137-
138-
# Store original method if needed
139-
if not hasattr(DataFrame, "_original_repr_html_"):
140-
DataFrame._original_repr_html_ = DataFrame._repr_html_
141-
142-
# Define patched method
143-
def patched_repr_html(self):
144-
"""Return HTML representation using configured formatter."""
145-
from datafusion.html_formatter import get_formatter
146-
147-
formatter = get_formatter()
148-
batches = self.collect()
149-
schema = self.schema()
150-
return formatter.format_html(batches, schema)
151-
152-
# Apply the patch
153-
DataFrame._repr_html_ = patched_repr_html
154-
except (ImportError, AttributeError) as e:
155-
print(f"Warning: Could not patch DataFrame._repr_html_: {e}")
156-
157-
158-
# Apply the patch when module is imported
159-
_patch_dataframe_repr_html()

0 commit comments

Comments
 (0)