Skip to content

Commit

Permalink
Move (str, enum.Enum) to StrEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneTorap committed Jul 31, 2023
1 parent 6df9450 commit e96b24c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enable=
# --disable=W"
disable=
cyclic-import, # re-enable once this no longer raises false positives
no-member, # re-enable once this no longer raises false positives
no-member, # re-enable once this no longer raises false positives. This will become redundant after the min required version is 3.11
missing-docstring,
duplicate-code,
unspecified-encoding,
Expand Down
6 changes: 3 additions & 3 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from __future__ import annotations

import builtins
import enum
import json
import logging
import textwrap
Expand Down Expand Up @@ -74,6 +73,7 @@
from superset.result_set import SupersetResultSet
from superset.superset_typing import ResultSetColumnType
from superset.utils import cache as cache_util, core as utils
from superset.utils.backports import StrEnum
from superset.utils.core import get_username

config = app.config
Expand Down Expand Up @@ -116,7 +116,7 @@ class CssTemplate(Model, AuditMixinNullable):
css = Column(Text, default="")


class ConfigurationMethod(str, enum.Enum):
class ConfigurationMethod(StrEnum):
SQLALCHEMY_FORM = "sqlalchemy_form"
DYNAMIC_FORM = "dynamic_form"

Expand Down Expand Up @@ -1007,7 +1007,7 @@ class Log(Model): # pylint: disable=too-few-public-methods
referrer = Column(String(1024))


class FavStarClassName(str, enum.Enum):
class FavStarClassName(StrEnum):
CHART = "slice"
DASHBOARD = "Dashboard"

Expand Down
17 changes: 8 additions & 9 deletions superset/reports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# specific language governing permissions and limitations
# under the License.
"""A collection of ORM sqlalchemy models for Superset"""
import enum

from cron_descriptor import get_description
from flask_appbuilder import Model
from flask_appbuilder.models.decorators import renders
Expand All @@ -41,48 +39,49 @@
from superset.models.helpers import AuditMixinNullable, ExtraJSONMixin
from superset.models.slice import Slice
from superset.reports.types import ReportScheduleExtra
from superset.utils.backports import StrEnum

metadata = Model.metadata # pylint: disable=no-member


class ReportScheduleType(str, enum.Enum):
class ReportScheduleType(StrEnum):
ALERT = "Alert"
REPORT = "Report"


class ReportScheduleValidatorType(str, enum.Enum):
class ReportScheduleValidatorType(StrEnum):
"""Validator types for alerts"""

NOT_NULL = "not null"
OPERATOR = "operator"


class ReportRecipientType(str, enum.Enum):
class ReportRecipientType(StrEnum):
EMAIL = "Email"
SLACK = "Slack"


class ReportState(str, enum.Enum):
class ReportState(StrEnum):
SUCCESS = "Success"
WORKING = "Working"
ERROR = "Error"
NOOP = "Not triggered"
GRACE = "On Grace"


class ReportDataFormat(str, enum.Enum):
class ReportDataFormat(StrEnum):
VISUALIZATION = "PNG"
DATA = "CSV"
TEXT = "TEXT"


class ReportCreationMethod(str, enum.Enum):
class ReportCreationMethod(StrEnum):
CHARTS = "charts"
DASHBOARDS = "dashboards"
ALERTS_REPORTS = "alerts_reports"


class ReportSourceFormat(str, enum.Enum):
class ReportSourceFormat(StrEnum):
CHART = "chart"
DASHBOARD = "dashboard"

Expand Down
4 changes: 2 additions & 2 deletions superset/sqllab/limiting_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import enum
from superset.utils.backports import StrEnum


class LimitingFactor(str, enum.Enum):
class LimitingFactor(StrEnum):
QUERY = "QUERY"
DROPDOWN = "DROPDOWN"
QUERY_AND_DROPDOWN = "QUERY_AND_DROPDOWN"
Expand Down

0 comments on commit e96b24c

Please sign in to comment.