Skip to content

Commit a6792c9

Browse files
committed
refactor: extract Python formatter retrieval into a separate function
1 parent e089d7b commit a6792c9

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/dataframe.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,15 @@ impl Default for FormatterConfig {
9393
}
9494
}
9595

96-
fn get_formatter_config(py: Python) -> PyResult<FormatterConfig> {
96+
/// Get the Python formatter from the datafusion.html_formatter module
97+
fn get_python_formatter(py: Python) -> PyResult<Bound<'_, PyAny>> {
9798
let formatter_module = py.import("datafusion.html_formatter")?;
9899
let get_formatter = formatter_module.getattr("get_formatter")?;
99-
let formatter = get_formatter.call0()?;
100+
get_formatter.call0()
101+
}
102+
103+
fn get_formatter_config(py: Python) -> PyResult<FormatterConfig> {
104+
let formatter = get_python_formatter(py)?;
100105

101106
// Helper function to extract attributes with fallback to default
102107
fn get_attr<'a>(
@@ -205,9 +210,7 @@ impl PyDataFrame {
205210
let py_schema = self.schema().into_pyobject(py)?;
206211

207212
// Get the Python formatter module and call format_html
208-
let formatter_module = py.import("datafusion.html_formatter")?;
209-
let get_formatter = formatter_module.getattr("get_formatter")?;
210-
let formatter = get_formatter.call0()?;
213+
let formatter = get_python_formatter(py)?;
211214

212215
// Call format_html method on the formatter
213216
let kwargs = pyo3::types::PyDict::new(py);

0 commit comments

Comments
 (0)