Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 647927f

Browse files
committed
chore: suppress python version support warnings
1 parent 33e1d4e commit 647927f

File tree

3 files changed

+51
-35
lines changed

3 files changed

+51
-35
lines changed

bigframes/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
"""BigQuery DataFrames provides a DataFrame API scaled by the BigQuery engine."""
1616

17+
import warnings
18+
1719
from bigframes._config import option_context, options
1820
from bigframes._config.bigquery_options import BigQueryOptions
1921
from bigframes.core.global_session import close_session, get_global_session
@@ -22,6 +24,14 @@
2224
from bigframes.session import connect, Session
2325
from bigframes.version import __version__
2426

27+
# Suppress Python version support warnings from google-cloud libraries.
28+
# These are particularly noisy in Colab which still uses Python 3.10.
29+
warnings.filterwarnings(
30+
"ignore",
31+
category=FutureWarning,
32+
message=".*Google will stop supporting.*Python.*",
33+
)
34+
2535
_MAGIC_NAMES = ["bqsql"]
2636

2737

bigframes/_magics.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import warnings
16+
1517
from IPython.core import magic_arguments # type: ignore
1618
from IPython.core.getipython import get_ipython
1719
from IPython.display import display
@@ -42,9 +44,11 @@ def _cell_magic(line, cell):
4244
print("Query is missing.")
4345
return
4446
pyformat_args = ipython.user_ns
45-
dataframe = bigframes.pandas._read_gbq_colab(
46-
cell, pyformat_args=pyformat_args, dry_run=args.dry_run
47-
)
47+
with warnings.catch_warnings():
48+
warnings.simplefilter("ignore", category=FutureWarning)
49+
dataframe = bigframes.pandas._read_gbq_colab(
50+
cell, pyformat_args=pyformat_args, dry_run=args.dry_run
51+
)
4852
if args.destination_var:
4953
ipython.push({args.destination_var: dataframe})
5054

bigframes/pandas/io/api.py

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -328,33 +328,35 @@ def _read_gbq_colab(
328328
if pyformat_args is None:
329329
pyformat_args = {}
330330

331-
# Only try to set the global location if it's not a dry run. We don't want
332-
# to bind to a location too early. This is especially important if the query
333-
# only refers to local data and not any BigQuery tables.
334-
if dry_run:
335-
result = _try_read_gbq_colab_sessionless_dry_run(
336-
query_or_table, pyformat_args=pyformat_args
337-
)
331+
with warnings.catch_warnings():
332+
warnings.simplefilter("ignore", category=FutureWarning)
333+
334+
# Only try to set the global location if it's not a dry run. We don't want
335+
# to bind to a location too early. This is especially important if the query
336+
# only refers to local data and not any BigQuery tables.
337+
if dry_run:
338+
result = _try_read_gbq_colab_sessionless_dry_run(
339+
query_or_table, pyformat_args=pyformat_args
340+
)
338341

339-
if result is not None:
340-
return result
341-
342-
# If we made it this far, we must have a session that has already
343-
# started. That means we can safely call the "real" _read_gbq_colab,
344-
# which generates slightly nicer SQL.
345-
else:
346-
# Delay formatting the query with the special "session-less" logic. This
347-
# avoids doing unnecessary work if the session already has a location or has
348-
# already started.
349-
create_query = functools.partial(
350-
bigframes.core.pyformat.pyformat,
351-
query_or_table,
352-
pyformat_args=pyformat_args,
353-
dry_run=True,
354-
)
355-
_set_default_session_location_if_possible_deferred_query(create_query)
356-
if not config.options.bigquery._session_started:
357-
with warnings.catch_warnings():
342+
if result is not None:
343+
return result
344+
345+
# If we made it this far, we must have a session that has already
346+
# started. That means we can safely call the "real" _read_gbq_colab,
347+
# which generates slightly nicer SQL.
348+
else:
349+
# Delay formatting the query with the special "session-less" logic. This
350+
# avoids doing unnecessary work if the session already has a location or has
351+
# already started.
352+
create_query = functools.partial(
353+
bigframes.core.pyformat.pyformat,
354+
query_or_table,
355+
pyformat_args=pyformat_args,
356+
dry_run=True,
357+
)
358+
_set_default_session_location_if_possible_deferred_query(create_query)
359+
if not config.options.bigquery._session_started:
358360
# Don't warning about Polars in SQL cell.
359361
# Related to b/437090788.
360362
try:
@@ -364,12 +366,12 @@ def _read_gbq_colab(
364366
except ImportError:
365367
pass # don't fail if polars isn't available
366368

367-
return global_session.with_default_session(
368-
bigframes.session.Session._read_gbq_colab,
369-
query_or_table,
370-
pyformat_args=pyformat_args,
371-
dry_run=dry_run,
372-
)
369+
return global_session.with_default_session(
370+
bigframes.session.Session._read_gbq_colab,
371+
query_or_table,
372+
pyformat_args=pyformat_args,
373+
dry_run=dry_run,
374+
)
373375

374376

375377
def read_gbq_model(model_name: str):

0 commit comments

Comments
 (0)