mirror of
https://github.com/apache/superset.git
synced 2026-04-10 20:06:13 +00:00
chore(pre-commit): Add pyupgrade and pycln hooks (#24197)
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
|
||||
from typing import Any, Callable, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
from flask_babel import gettext as _
|
||||
@@ -27,11 +27,11 @@ from superset.utils.pandas_postprocessing.aggregate import aggregate
|
||||
|
||||
def boxplot(
|
||||
df: DataFrame,
|
||||
groupby: List[str],
|
||||
metrics: List[str],
|
||||
groupby: list[str],
|
||||
metrics: list[str],
|
||||
whisker_type: PostProcessingBoxplotWhiskerType,
|
||||
percentiles: Optional[
|
||||
Union[List[Union[int, float]], Tuple[Union[int, float], Union[int, float]]]
|
||||
Union[list[Union[int, float]], tuple[Union[int, float], Union[int, float]]]
|
||||
] = None,
|
||||
) -> DataFrame:
|
||||
"""
|
||||
@@ -102,12 +102,12 @@ def boxplot(
|
||||
whisker_high = np.max
|
||||
whisker_low = np.min
|
||||
|
||||
def outliers(series: Series) -> Set[float]:
|
||||
def outliers(series: Series) -> set[float]:
|
||||
above = series[series > whisker_high(series)]
|
||||
below = series[series < whisker_low(series)]
|
||||
return above.tolist() + below.tolist()
|
||||
|
||||
operators: Dict[str, Callable[[Any], Any]] = {
|
||||
operators: dict[str, Callable[[Any], Any]] = {
|
||||
"mean": np.mean,
|
||||
"median": np.median,
|
||||
"max": whisker_high,
|
||||
@@ -117,7 +117,7 @@ def boxplot(
|
||||
"count": np.ma.count,
|
||||
"outliers": outliers,
|
||||
}
|
||||
aggregates: Dict[str, Dict[str, Union[str, Callable[..., Any]]]] = {
|
||||
aggregates: dict[str, dict[str, Union[str, Callable[..., Any]]]] = {
|
||||
f"{metric}__{operator_name}": {"column": metric, "operator": operator}
|
||||
for operator_name, operator in operators.items()
|
||||
for metric in metrics
|
||||
|
||||
Reference in New Issue
Block a user