Skip to content

Commit cae89b0

Browse files
committed
Fix ruff errors
1 parent 929563a commit cae89b0

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

python/datafusion/dataframe.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import pyarrow as pa
5050

5151
from datafusion._internal import DataFrame as DataFrameInternal
52+
from datafusion._internal import DisplayConfig
5253
from datafusion._internal import expr as expr_internal
5354

5455
from enum import Enum
@@ -823,14 +824,17 @@ def configure_display(
823824
"""Configure display options for DataFrame representation.
824825
825826
Args:
826-
max_table_bytes: Maximum bytes to display for table presentation (default: 2MB).
827+
max_table_bytes: Maximum bytes to display for table presentation
828+
(default: 2MB).
827829
Set to lower value for large tables to limit memory usage.
828830
min_table_rows: Minimum number of table rows to display (default: 20).
829831
This is used for initial display and in notebooks.
830-
max_cell_length: Maximum length of a cell before it gets minimized (default: 25).
832+
max_cell_length: Maximum length of a cell before it gets minimized
833+
(default: 25).
831834
Longer cells will be truncated with an expand button.
832-
max_table_rows_in_repr: Maximum number of rows to display in string representation
833-
(default: 10).
835+
max_table_rows_in_repr: Maximum number of rows to display in string
836+
representation
837+
(default: 10).
834838
835839
Raises:
836840
ValueError: If any of the provided values are less than or equal to 0.
@@ -844,7 +848,8 @@ def configure_display(
844848
max_table_rows_in_repr,
845849
)
846850
):
847-
raise ValueError("All values must be greater than 0.")
851+
error_msg = "All values must be greater than 0."
852+
raise ValueError(error_msg)
848853

849854
self.df.configure_display(
850855
max_table_bytes, min_table_rows, max_cell_length, max_table_rows_in_repr
@@ -855,8 +860,12 @@ def reset_display_config(self) -> None:
855860
self.df.reset_display_config()
856861

857862
@property
858-
def display_config(self):
859-
"""Get the current display configuration."""
863+
def display_config(self) -> DisplayConfig:
864+
"""Get the current display configuration.
865+
866+
Returns:
867+
DisplayConfig: The current display configuration settings
868+
"""
860869
return self.df.display_config
861870

862871
@deprecated("Use :py:func:`unnest_columns` instead.")

python/tests/test_dataframe.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,8 @@ def test_configure_display(df):
13061306

13071307
# Test with negative values
13081308
# This tests for expected behavior when users accidentally pass negative values
1309-
# Since these are usize in Rust, we expect a Python ValueError when trying to pass negative values
1309+
# Since these are usize in Rust, we expect a Python ValueError when trying to pass
1310+
# negative values.
13101311
with pytest.raises(ValueError, match=r".*must be greater than 0.*"):
13111312
df.configure_display(max_table_bytes=-1)
13121313

@@ -1393,9 +1394,10 @@ def test_max_table_bytes_display(ctx):
13931394
limited_row_count = limited_html.count("<tr>") - 1
13941395

13951396
# Verify fewer rows are displayed with the byte limit
1396-
assert (
1397-
limited_row_count < default_row_count
1398-
), f"Expected fewer rows with byte limit. Default: {default_row_count}, Limited: {limited_row_count}"
1397+
assert limited_row_count < default_row_count, (
1398+
f"Expected fewer rows with byte limit. "
1399+
f"Default: {default_row_count}, Limited: {limited_row_count}"
1400+
)
13991401

14001402
# "Data truncated" should be present when limited
14011403
assert "Data truncated" in limited_html
@@ -1504,7 +1506,9 @@ def _create_numeric_test_df(ctx, rows) -> DataFrame:
15041506

15051507

15061508
def test_max_table_rows_in_repr(ctx):
1507-
"""Test that max_table_rows_in_repr controls the number of rows in string representation."""
1509+
"""Test that max_table_rows_in_repr controls the number of rows in string
1510+
representation.
1511+
"""
15081512
# Create a dataframe with more rows than the default max_table_rows_in_repr (10)
15091513
rows = 20
15101514
df = _create_numeric_test_df(ctx, rows)

0 commit comments

Comments
 (0)