From 61a90c420697d0c0e4a3a798561560f832a20cbc Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Thu, 20 Jan 2022 14:24:23 +0000 Subject: [PATCH 1/2] fix: logging warning on dataframe (don't use python's warnings) --- superset/dataframe.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/superset/dataframe.py b/superset/dataframe.py index b0e7a0e24304..416a11424044 100644 --- a/superset/dataframe.py +++ b/superset/dataframe.py @@ -16,13 +16,14 @@ # under the License. """ Superset utilities for pandas.DataFrame. """ -import warnings +import logging from typing import Any, Dict, List import pandas as pd from superset.utils.core import JS_MAX_INTEGER +logger = logging.getLogger(__name__) def _convert_big_integers(val: Any) -> Any: """ @@ -43,10 +44,8 @@ def df_to_records(dframe: pd.DataFrame) -> List[Dict[str, Any]]: :returns: a list of dictionaries reflecting each single row of the DataFrame """ if not dframe.columns.is_unique: - warnings.warn( + logger.warning( "DataFrame columns are not unique, some columns will be omitted.", - UserWarning, - stacklevel=2, ) columns = dframe.columns return list( From 8ad55f562cf3fe79a448842fcc0010c87c997038 Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Thu, 20 Jan 2022 14:56:50 +0000 Subject: [PATCH 2/2] lint --- superset/dataframe.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/dataframe.py b/superset/dataframe.py index 416a11424044..8abeedc09529 100644 --- a/superset/dataframe.py +++ b/superset/dataframe.py @@ -25,6 +25,7 @@ logger = logging.getLogger(__name__) + def _convert_big_integers(val: Any) -> Any: """ Cast integers larger than ``JS_MAX_INTEGER`` to strings. @@ -45,7 +46,7 @@ def df_to_records(dframe: pd.DataFrame) -> List[Dict[str, Any]]: """ if not dframe.columns.is_unique: logger.warning( - "DataFrame columns are not unique, some columns will be omitted.", + "DataFrame columns are not unique, some columns will be omitted." ) columns = dframe.columns return list(