Skip to content

Commit 3bc2ad9

Browse files
matrixstonelqc
authored andcommitted
Add support for Python 3.11
Changes made: * Replace usage of Enum plus str mixin with StrEnum, as per python/cpython#100458
1 parent 295264d commit 3bc2ad9

File tree

79 files changed

+241
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+241
-241
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
runs-on: ubuntu-latest
5151
strategy:
5252
matrix:
53-
python-version: ["3.8", "3.9", "3.10"]
53+
python-version: ["3.8", "3.9", "3.10", "3.11"]
5454
needs: check-code-quality
5555
steps:
5656
- uses: actions/checkout@v3

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10-bookworm
1+
FROM python:3.11-bookworm
22
LABEL description="Deploy Mage on ECS"
33
ARG FEATURE_BRANCH
44
USER root

docs/contributing/charts/how-to-add.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebarTitle: "Charts"
88
Add a new type in [`mage_ai/data_preparation/models/widget/constants.py`](https://github.com/mage-ai/mage-ai/blob/master/mage_ai/data_preparation/models/widget/constants.py):
99

1010
```python
11-
class ChartType(str, Enum):
11+
class ChartType(StrEnum):
1212
# ...
1313
PIE_CHART = 'pie_chart'
1414
```

mage_ai/ai/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33

4-
class LLMUseCase(str, Enum):
4+
class LLMUseCase(StrEnum):
55
GENERATE_DOC_FOR_BLOCK = 'generate_doc_for_block'
66
GENERATE_DOC_FOR_PIPELINE = 'generate_doc_for_pipeline'
77
GENERATE_BLOCK_WITH_DESCRIPTION = 'generate_block_with_description'

mage_ai/api/constants.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33
from mage_ai.api.operations.constants import OperationType
44
from mage_ai.orchestration.db.models.oauth import Permission
55

66

7-
class AttributeOperationType(str, Enum):
7+
class AttributeOperationType(StrEnum):
88
QUERY = 'query'
99
READ = 'read'
1010
WRITE = 'write'
1111

1212

13-
class AttributeType(str, Enum):
13+
class AttributeType(StrEnum):
1414
ALL = '__*MAGE*__'
1515

1616

17-
class AuthorizeStatusType(str, Enum):
17+
class AuthorizeStatusType(StrEnum):
1818
ALL = 'all'
1919
FAILED = 'failed'
2020
SUCCEEDED = 'succeeded'

mage_ai/api/oauth_scope.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33

44
class OauthScope():
@@ -18,7 +18,7 @@ class OauthScope():
1818
TOKEN_SCOPES = []
1919

2020

21-
class OauthScopeType(str, Enum):
21+
class OauthScopeType(StrEnum):
2222
CLIENT_ALL = 'all'
2323
CLIENT_INTERNAL = 'internal'
2424
CLIENT_PRIVATE = 'private'

mage_ai/api/operations/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33
ALL = 'all'
44
CREATE = 'create'
@@ -20,7 +20,7 @@
2020
COOKIE_PREFIX = '__COOKIE__'
2121

2222

23-
class OperationType(str, Enum):
23+
class OperationType(StrEnum):
2424
ALL = ALL
2525
CREATE = CREATE
2626
DELETE = DELETE

mage_ai/authentication/oauth/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from enum import Enum
1+
from enum import StrEnum
22
from typing import Optional
33

44
from mage_ai.settings import get_settings_value
@@ -10,7 +10,7 @@
1010
GITHUB_STATE = '1337'
1111

1212

13-
class ProviderName(str, Enum):
13+
class ProviderName(StrEnum):
1414
ACTIVE_DIRECTORY = 'active_directory'
1515
AZURE_DEVOPS = 'azure_devops'
1616
BITBUCKET = 'bitbucket'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33
MAGE_OPERATION_HISTORY_DIRECTORY_DEFAULT = '.operation_history'
44
MAGE_OPERATION_HISTORY_DIRECTORY_ENVIRONMENT_VARIABLE_NAME = 'MAGE_OPERATION_HISTORY_DIRECTORY'
55

66

7-
class ResourceType(str, Enum):
7+
class ResourceType(StrEnum):
88
PIPELINE = 'pipeline'

mage_ai/authentication/permissions/constants.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from enum import Enum
1+
from enum import IntEnum, StrEnum
22

33
from mage_ai.api.operations.constants import OperationType
44
from mage_ai.data_preparation.models.constants import BlockType, PipelineType
55

66

7-
class EntityName(str, Enum):
7+
class EntityName(StrEnum):
88
ALL = 'ALL'
99
ALL_EXCEPT_RESERVED = 'ALL_EXCEPT_RESERVED'
1010
AutocompleteItem = 'AutocompleteItem'
@@ -103,7 +103,7 @@ class EntityName(str, Enum):
103103
]
104104

105105

106-
class BaseEntityType(str, Enum):
106+
class BaseEntityType(StrEnum):
107107
pass
108108

109109

@@ -131,7 +131,7 @@ class PipelineEntityType(BaseEntityType):
131131
STREAMING = PipelineType.STREAMING.value
132132

133133

134-
class PermissionAccess(int, Enum):
134+
class PermissionAccess(IntEnum):
135135
OWNER = 1
136136
ADMIN = 2
137137
# Editor: list, detail, create, update, delete
@@ -171,7 +171,7 @@ class PermissionAccess(int, Enum):
171171
DISABLE_UNLESS_CONDITIONS = 1073741824
172172

173173

174-
class PermissionCondition(str, Enum):
174+
class PermissionCondition(StrEnum):
175175
HAS_NOTEBOOK_EDIT_ACCESS = 'HAS_NOTEBOOK_EDIT_ACCESS'
176176
HAS_PIPELINE_EDIT_ACCESS = 'HAS_PIPELINE_EDIT_ACCESS'
177177
USER_OWNS_ENTITY = 'USER_OWNS_ENTITY'

mage_ai/cache/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33
CACHE_KEY_BLOCKS_TO_PIPELINE_MAPPING = 'blocks_to_pipeline_mapping'
44
CACHE_KEY_BLOCK_ACTION_OBJECTS_MAPPING = 'block_action_objects_mapping'
@@ -11,5 +11,5 @@
1111
MAGE_CACHE_DIRECTORY_ENVIRONMENT_VARIABLE_NAME = 'MAGE_CACHE_DIRECTORY'
1212

1313

14-
class CacheItemType(str, Enum):
14+
class CacheItemType(StrEnum):
1515
DBT = 'dbt'

mage_ai/cache/dbt/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33
from mage_ai.data_preparation.models.constants import (
44
BLOCK_TYPE_DIRECTORY_NAME,
@@ -19,7 +19,7 @@
1919
PROJECT_FILENAMES = [PROJECT_FILENAME, 'dbt_project.yaml']
2020

2121

22-
class FileType(str, Enum):
22+
class FileType(StrEnum):
2323
MODEL = 'model'
2424
PROFILES = 'profiles'
2525
PROJECT = 'project'

mage_ai/cluster_manager/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33
# ECS environment variables
44
ECS_CLUSTER_NAME = 'ECS_CLUSTER_NAME'
@@ -29,7 +29,7 @@
2929
NODE_PORT_SERVICE_TYPE = 'NodePort'
3030

3131

32-
class ClusterType(str, Enum):
32+
class ClusterType(StrEnum):
3333
EMR = 'emr'
3434
ECS = 'ecs'
3535
CLOUD_RUN = 'cloud_run'

mage_ai/command_center/constants.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33
SETTINGS_FILENAME = '.command_center.yaml'
44

55

6-
class ItemTagEnum(str, Enum):
6+
class ItemTagEnum(StrEnum):
77
PINNED = 'pinned'
88
RECENT = 'recent'
99

1010

11-
class ItemType(str, Enum):
11+
class ItemType(StrEnum):
1212
ACTION = 'action' # Cast spell
1313
CREATE = 'create' # Conjure
1414
DELETE = 'delete'
@@ -22,7 +22,7 @@ class ItemType(str, Enum):
2222
UPDATE = 'update'
2323

2424

25-
class ObjectType(str, Enum):
25+
class ObjectType(StrEnum):
2626
APPLICATION = 'application'
2727
APPLICATION_EXPANSION = 'application_expansion'
2828
AUTHENTICATION = 'authentication'
@@ -42,11 +42,11 @@ class ObjectType(str, Enum):
4242
VERSION_CONTROL_FILE = 'version_control_file'
4343

4444

45-
class ModeType(str, Enum):
45+
class ModeType(StrEnum):
4646
VERSION_CONTROL = 'version_control'
4747

4848

49-
class FileExtension(str, Enum):
49+
class FileExtension(StrEnum):
5050
CSV = 'csv'
5151
JSON = 'json'
5252
MD = 'md'
@@ -59,7 +59,7 @@ class FileExtension(str, Enum):
5959
YML = 'yml'
6060

6161

62-
class ButtonActionType(str, Enum):
62+
class ButtonActionType(StrEnum):
6363
ADD_APPLICATION = 'add_application'
6464
CLOSE_APPLICATION = 'close_application' # Go back out of the current application.
6565
CLOSE_COMMAND_CENTER = 'close_command_center'
@@ -70,7 +70,7 @@ class ButtonActionType(str, Enum):
7070
SELECT_ITEM_FROM_REQUEST = 'select_item_from_request'
7171

7272

73-
class InteractionType(str, Enum):
73+
class InteractionType(StrEnum):
7474
CLICK = 'click'
7575
CLOSE_APPLICATION = ButtonActionType.CLOSE_APPLICATION.value
7676
CLOSE_COMMAND_CENTER = ButtonActionType.CLOSE_COMMAND_CENTER.value
@@ -81,30 +81,30 @@ class InteractionType(str, Enum):
8181
SELECT_ITEM = 'select_item'
8282

8383

84-
class ApplicationType(str, Enum):
84+
class ApplicationType(StrEnum):
8585
DETAIL = 'detail'
8686
DETAIL_LIST = 'detail_list'
8787
EXPANSION = 'expansion'
8888
FORM = 'form'
8989
LIST = 'list'
9090

9191

92-
class ValidationType(str, Enum):
92+
class ValidationType(StrEnum):
9393
CONFIRMATION = 'confirmation'
9494
CUSTOM_VALIDATION_PARSERS = 'custom_validation_parsers'
9595

9696

97-
class RenderLocationType(str, Enum):
97+
class RenderLocationType(StrEnum):
9898
ITEMS_CONTAINER_AFTER = 'items_container_after'
9999

100100

101-
class ApplicationExpansionUUID(str, Enum):
101+
class ApplicationExpansionUUID(StrEnum):
102102
ArcaneLibrary = 'ArcaneLibrary'
103103
PortalTerminal = 'PortalTerminal'
104104
VersionControlFileDiffs = 'VersionControlFileDiffs'
105105

106106

107-
class ApplicationExpansionStatus(str, Enum):
107+
class ApplicationExpansionStatus(StrEnum):
108108
ACTIVE = 'ACTIVE'
109109
CLOSED = 'CLOSED'
110110
INACTIVE = 'INACTIVE'

mage_ai/data_cleaner/column_types/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33

4-
class ColumnType(str, Enum):
4+
class ColumnType(StrEnum):
55
CATEGORY = 'category'
66
CATEGORY_HIGH_CARDINALITY = 'category_high_cardinality'
77
DATETIME = 'datetime'

mage_ai/data_cleaner/transformer_actions/constants.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from mage_ai.data_cleaner.column_types.constants import ColumnType
2-
from enum import Enum
3-
import pandas as pd
4-
import numpy as np
51
import re
2+
from enum import StrEnum
63

4+
import numpy as np
5+
import pandas as pd
6+
7+
from mage_ai.data_cleaner.column_types.constants import ColumnType
78

89
CONSTANT_IMPUTATION_DEFAULTS = {
910
ColumnType.CATEGORY: 'missing',
@@ -34,7 +35,7 @@
3435
}
3536

3637

37-
class ActionType(str, Enum):
38+
class ActionType(StrEnum):
3839
ADD = 'add'
3940
AVERAGE = 'average'
4041
CLEAN_COLUMN_NAME = 'clean_column_name'
@@ -73,18 +74,18 @@ class ActionType(str, Enum):
7374
STANDARDIZE = 'standardize'
7475

7576

76-
class Axis(str, Enum):
77+
class Axis(StrEnum):
7778
COLUMN = 'column'
7879
ROW = 'row'
7980

8081

81-
class VariableType(str, Enum):
82+
class VariableType(StrEnum):
8283
FEATURE = 'feature'
8384
FEATURE_SET = 'feature_set'
8485
FEATURE_SET_VERSION = 'feature_set_version'
8586

8687

87-
class Operator(str, Enum):
88+
class Operator(StrEnum):
8889
CONTAINS = 'contains'
8990
NOT_CONTAINS = 'not contains'
9091
EQUALS = '=='
@@ -95,7 +96,7 @@ class Operator(str, Enum):
9596
LESS_THAN_OR_EQUALS = '<='
9697

9798

98-
class ImputationStrategy(str, Enum):
99+
class ImputationStrategy(StrEnum):
99100
AVERAGE = 'average'
100101
COLUMN = 'column'
101102
CONSTANT = 'constant'

mage_ai/data_preparation/logging/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from dataclasses import dataclass, field
2-
from enum import Enum
2+
from enum import StrEnum
33
from typing import Dict
44

55
from mage_ai.shared.config import BaseConfig
66
from mage_ai.shared.logger import LoggingLevel
77

88

9-
class LoggerType(str, Enum):
9+
class LoggerType(StrEnum):
1010
DEFAULT = 'file'
1111
S3 = 's3'
1212
GCS = 'gcs'

mage_ai/data_preparation/models/block/data_integration/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from enum import Enum
1+
from enum import StrEnum
22

33
BLOCK_CATALOG_FILENAME = 'catalog.json'
44
REPLICATION_METHOD_INCREMENTAL = 'INCREMENTAL'
@@ -81,6 +81,6 @@
8181
VARIABLE_BOOKMARK_VALUES_KEY = '__bookmark_values__'
8282

8383

84-
class IngestMode(str, Enum):
84+
class IngestMode(StrEnum):
8585
DISK = 'disk'
8686
MEMORY = 'memory'

0 commit comments

Comments
 (0)