Skip to content

Commit

Permalink
fix: update pylint disabled checks in common/query_context.py (#10941)
Browse files Browse the repository at this point in the history
* Updated common/query_context.py
- removed disabled pylint rule no-self-use from `df_metrics_to_num` since it has `@staticmethod`
- applied black on the file

* Removed disabled lint check `too-many-locals` in get_df_payload method. Applied black.

* Method `get_data()` has self param:
- removing # pylint: disable=no-self-use
- autoformatting
  • Loading branch information
kkucharc authored Sep 18, 2020
1 parent 141ef4a commit e21a354
Showing 1 changed file with 3 additions and 7 deletions.
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

0 comments on commit e21a354

Please sign in to comment.