Skip to content

BUG: only show verbose warning for new pandas versions. #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

0.4.1 / 2018-04-05
------------------

- Only show ``verbose`` deprecation warning if Pandas version does not
populate it. (:issue:`157`)

0.4.0 / 2018-04-03
------------------

Expand Down
20 changes: 15 additions & 5 deletions pandas_gbq/gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@


BIGQUERY_INSTALLED_VERSION = None
PANDAS_HAS_DEPRECATED_VERBOSITY = False


def _check_google_client_version():
global BIGQUERY_INSTALLED_VERSION
global BIGQUERY_INSTALLED_VERSION, PANDAS_HAS_DEPRECATED_VERBOSITY

try:
import pkg_resources
Expand All @@ -36,6 +37,14 @@ def _check_google_client_version():
'current version {1}'.format(
bigquery_minimum_version, BIGQUERY_INSTALLED_VERSION))

# Add check for Pandas version before showing deprecation warning.
# https://github.com/pydata/pandas-gbq/issues/157
pandas_installed_version = pkg_resources.get_distribution(
'pandas').parsed_version
pandas_version_wo_verbosity = pkg_resources.parse_version('0.23.0')
PANDAS_HAS_DEPRECATED_VERBOSITY = (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F841 local variable 'PANDAS_HAS_DEPRECATED_VERBOSITY' is assigned to but never used

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just amended the commit to add the global declaration.

pandas_installed_version >= pandas_version_wo_verbosity)


def _test_google_api_imports():

Expand Down Expand Up @@ -791,14 +800,15 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None,
DataFrame representing results of query

"""
if verbose is not None:

_test_google_api_imports()

if verbose is not None and PANDAS_HAS_DEPRECATED_VERBOSITY:
warnings.warn(
"verbose is deprecated and will be removed in "
"a future version. Set logging level in order to vary "
"verbosity", FutureWarning, stacklevel=1)

_test_google_api_imports()

if not project_id:
raise TypeError("Missing required parameter: project_id")

Expand Down Expand Up @@ -920,7 +930,7 @@ def to_gbq(dataframe, destination_table, project_id, chunksize=None,

_test_google_api_imports()

if verbose is not None:
if verbose is not None and PANDAS_HAS_DEPRECATED_VERBOSITY:
warnings.warn(
"verbose is deprecated and will be removed in "
"a future version. Set logging level in order to vary "
Expand Down