Skip to content

Commit da2f536

Browse files
committed
polish python function
1 parent 84a7b3d commit da2f536

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

bigframes/display/anywidget.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424

2525
import bigframes
2626

27-
# Follow the same pattern as Polars
28-
anywidget_installed = True
27+
ANYWIDGET_INSTALLED = True
2928
if TYPE_CHECKING:
3029
import anywidget
3130
import traitlets
@@ -34,21 +33,22 @@
3433
import anywidget
3534
import traitlets
3635
except Exception:
37-
anywidget_installed = False
36+
ANYWIDGET_INSTALLED = False
3837

3938

4039
class TableWidget(anywidget.AnyWidget):
4140
"""
4241
An interactive, paginated table widget for BigFrames DataFrames.
4342
"""
4443

45-
def __init__(self, dataframe):
44+
def __init__(self, dataframe: bigframes.dataframe.DataFrame):
4645
"""
4746
Initialize the TableWidget.
47+
4848
Args:
49-
dataframe: The Bigframes Dataframe to display.
49+
dataframe: The Bigframes Dataframe to display in the widget.
5050
"""
51-
if not anywidget_installed:
51+
if not ANYWIDGET_INSTALLED:
5252
raise ValueError("Anywidget is not installed, cannot create TableWidget.")
5353

5454
super().__init__()
@@ -62,7 +62,7 @@ def __init__(self, dataframe):
6262
self._cached_data = pd.DataFrame(columns=self._dataframe.columns)
6363
self._table_id = str(uuid.uuid4())
6464
self._all_data_loaded = False
65-
self._batch_iterator = None
65+
self._batch_iterator: Iterator[pd.DataFrame] | None = None
6666

6767
# len(dataframe) is expensive, since it will trigger a
6868
# SELECT COUNT(*) query. It is a must have however.
@@ -94,7 +94,8 @@ def _validate_page(self, proposal):
9494
def _get_next_batch(self) -> bool:
9595
"""
9696
Gets the next batch of data from the generator and appends to cache.
97-
Returns:
97+
98+
Return:
9899
bool: True if a batch was successfully loaded, False otherwise.
99100
"""
100101
if self._all_data_loaded:

0 commit comments

Comments
 (0)