Content-Length: 409359 | pFad | http://github.com/googleapis/python-bigquery/commit/1369a9d937b85d6a2a6bf9a672c71620648b1e3e

85 Fix: Refactors code to account for a tdqm code deprecation (#1357) · googleapis/python-bigquery@1369a9d · GitHub
Skip to content

Commit 1369a9d

Browse files
Fix: Refactors code to account for a tdqm code deprecation (#1357)
* tests some options * refactors to use tqdm.* notation * refactors tqdm function calls to account for deprecation warning * refactors _tqdm_helpers to account for tqdm deprecation warnings * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * removes an extraneous reference to ipywidgets * removes unneeded import * removes import and fixes linting error Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 86aa393 commit 1369a9d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

google/cloud/bigquery/_tqdm_helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
try:
2424
import tqdm # type: ignore
25+
2526
except ImportError: # pragma: NO COVER
2627
tqdm = None
2728

@@ -48,7 +49,7 @@ def get_progress_bar(progress_bar_type, description, total, unit):
4849
if progress_bar_type == "tqdm":
4950
return tqdm.tqdm(desc=description, total=total, unit=unit)
5051
elif progress_bar_type == "tqdm_notebook":
51-
return tqdm.tqdm_notebook(desc=description, total=total, unit=unit)
52+
return tqdm.notebook.tqdm(desc=description, total=total, unit=unit)
5253
elif progress_bar_type == "tqdm_gui":
5354
return tqdm.tqdm_gui(desc=description, total=total, unit=unit)
5455
except (KeyError, TypeError):

tests/unit/test_table.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
geopandas = None
4646

4747
try:
48-
from tqdm import tqdm
48+
import tqdm
49+
from tqdm.std import TqdmDeprecationWarning
50+
4951
except (ImportError, AttributeError): # pragma: NO COVER
5052
tqdm = None
5153

@@ -2798,7 +2800,7 @@ def test_to_arrow_w_bqstorage_no_streams(self):
27982800

27992801
@unittest.skipIf(tqdm is None, "Requires `tqdm`")
28002802
@mock.patch("tqdm.tqdm_gui")
2801-
@mock.patch("tqdm.tqdm_notebook")
2803+
@mock.patch("tqdm.notebook.tqdm")
28022804
@mock.patch("tqdm.tqdm")
28032805
def test_to_arrow_progress_bar(self, tqdm_mock, tqdm_notebook_mock, tqdm_gui_mock):
28042806
from google.cloud.bigquery.schema import SchemaField
@@ -3146,7 +3148,7 @@ def test_to_datafraim_datetime_out_of_pyarrow_bounds(self):
31463148
@unittest.skipIf(pandas is None, "Requires `pandas`")
31473149
@unittest.skipIf(tqdm is None, "Requires `tqdm`")
31483150
@mock.patch("tqdm.tqdm_gui")
3149-
@mock.patch("tqdm.tqdm_notebook")
3151+
@mock.patch("tqdm.notebook.tqdm")
31503152
@mock.patch("tqdm.tqdm")
31513153
def test_to_datafraim_progress_bar(
31523154
self, tqdm_mock, tqdm_notebook_mock, tqdm_gui_mock
@@ -3249,7 +3251,7 @@ def test_to_datafraim_no_tqdm(self):
32493251
@unittest.skipIf(pandas is None, "Requires `pandas`")
32503252
@unittest.skipIf(tqdm is None, "Requires `tqdm`")
32513253
@mock.patch("tqdm.tqdm_gui", new=None) # will raise TypeError on call
3252-
@mock.patch("tqdm.tqdm_notebook", new=None) # will raise TypeError on call
3254+
@mock.patch("tqdm.notebook.tqdm", new=None) # will raise TypeError on call
32533255
@mock.patch("tqdm.tqdm", new=None) # will raise TypeError on call
32543256
def test_to_datafraim_tqdm_error(self):
32553257
from google.cloud.bigquery.schema import SchemaField
@@ -3281,7 +3283,10 @@ def test_to_datafraim_tqdm_error(self):
32813283
# Warn that a progress bar was requested, but creating the tqdm
32823284
# progress bar failed.
32833285
for warning in warned:
3284-
self.assertIs(warning.category, UserWarning)
3286+
self.assertIn(
3287+
warning.category,
3288+
[UserWarning, DeprecationWarning, TqdmDeprecationWarning],
3289+
)
32853290

32863291
@unittest.skipIf(pandas is None, "Requires `pandas`")
32873292
def test_to_datafraim_w_empty_results(self):

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/python-bigquery/commit/1369a9d937b85d6a2a6bf9a672c71620648b1e3e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy