Skip to content

Commit 2dc22ec

Browse files
authored
chore: fix mypy errors, exclude experimental notebook from testing (#1083)
* chore: fix mypy errors * use quoted annotation to avoid error in non type-checking environment * exclude experimental semantic operators notebook from testing
1 parent 9d6d9dd commit 2dc22ec

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

bigframes/dataframe.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
import bigframes.session._io.bigquery
8282

8383
if typing.TYPE_CHECKING:
84+
from _typeshed import SupportsRichComparison
85+
8486
import bigframes.session
8587

8688
SingleItemValue = Union[bigframes.series.Series, int, float, Callable]
@@ -2464,7 +2466,7 @@ def pivot_table(
24642466
values = [values]
24652467

24662468
# Unlike pivot, pivot_table has values always ordered.
2467-
values.sort()
2469+
values.sort(key=lambda val: typing.cast("SupportsRichComparison", val))
24682470

24692471
keys = index + columns
24702472
agged = self.groupby(keys, dropna=True)[values].agg(aggfunc)

bigframes/session/loader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ def read_gbq_table(
300300
):
301301
# TODO(b/338111344): If we are running a query anyway, we might as
302302
# well generate ROW_NUMBER() at the same time.
303-
all_columns = itertools.chain(index_cols, columns) if columns else ()
303+
all_columns: Iterable[str] = (
304+
itertools.chain(index_cols, columns) if columns else ()
305+
)
304306
query = bf_io_bigquery.to_query(
305307
query,
306308
columns=all_columns,

bigframes/session/metrics.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def count_job_stats(self, query_job: bq_job.QueryJob):
4444

4545
def get_performance_stats(
4646
query_job: bigquery.QueryJob,
47-
) -> Optional[Tuple[int, int, float]]:
47+
) -> Optional[Tuple[int, int, Optional[float]]]:
4848
"""Parse the query job for performance stats.
4949
5050
Return None if the stats do not reflect real work done in bigquery.
@@ -73,7 +73,9 @@ def get_performance_stats(
7373
return bytes_processed, slot_millis, exec_seconds
7474

7575

76-
def write_stats_to_disk(bytes_processed: int, slot_millis: int, exec_seconds: float):
76+
def write_stats_to_disk(
77+
bytes_processed: int, slot_millis: int, exec_seconds: Optional[float]
78+
):
7779
"""For pytest runs only, log information about the query job
7880
to a file in order to create a performance report.
7981
"""

noxfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ def notebook(session: nox.Session):
744744
# The experimental notebooks imagine features that don't yet
745745
# exist or only exist as temporary prototypes.
746746
"notebooks/experimental/longer_ml_demo.ipynb",
747+
"notebooks/experimental/semantic_operators.ipynb",
747748
# The notebooks that are added for more use cases, such as backing a
748749
# blog post, which may take longer to execute and need not be
749750
# continuously tested.

0 commit comments

Comments
 (0)