Skip to content
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

fix: update pylint disabled checks in common/query_context.py #10941

Merged
merged 3 commits into from
Sep 18, 2020
Merged
Changes from all commits
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
10 changes: 3 additions & 7 deletions superset/common/query_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,13 @@ def get_query_result(self, query_object: QueryObject) -> Dict[str, Any]:
}

@staticmethod
def df_metrics_to_num( # pylint: disable=no-self-use
df: pd.DataFrame, query_object: QueryObject
) -> None:
def df_metrics_to_num(df: pd.DataFrame, query_object: QueryObject) -> None:
"""Converting metrics to numeric when pandas.read_sql cannot"""
for col, dtype in df.dtypes.items():
if dtype.type == np.object_ and col in query_object.metrics:
df[col] = pd.to_numeric(df[col], errors="coerce")

def get_data(
self, df: pd.DataFrame,
) -> Union[str, List[Dict[str, Any]]]: # pylint: disable=no-self-use
def get_data(self, df: pd.DataFrame,) -> Union[str, List[Dict[str, Any]]]:
if self.result_format == utils.ChartDataResultFormat.CSV:
include_index = not isinstance(df.index, pd.RangeIndex)
result = df.to_csv(index=include_index, **config["CSV_EXPORT"])
Expand Down Expand Up @@ -204,7 +200,7 @@ def cache_key(self, query_obj: QueryObject, **kwargs: Any) -> Optional[str]:
)
return cache_key

def get_df_payload( # pylint: disable=too-many-locals,too-many-statements
def get_df_payload( # pylint: disable=too-many-statements
self, query_obj: QueryObject, **kwargs: Any
) -> Dict[str, Any]:
"""Handles caching around the df payload retrieval"""
Expand Down