chore(pre-commit): Add pyupgrade and pycln hooks (#24197)

This commit is contained in:
John Bodley
2023-06-01 12:01:10 -07:00
committed by GitHub
parent 7d7ce63970
commit a4d5d7c6b9
448 changed files with 3084 additions and 3305 deletions

View File

@@ -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