Skip to content

Commit

Permalink
fix: EnumType is not available before 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshultz committed Sep 23, 2023
1 parent 6470544 commit 5597186
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rawl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def get_name(self, pk):
import logging
import random
import warnings
from enum import Enum, EnumType, IntEnum

# EnumMeta is an alias to EnumType as of 3.11 - to be depreciated
from enum import EnumMeta, IntEnum
from abc import ABC
from collections.abc import KeysView, ValuesView
from json import JSONEncoder
Expand Down Expand Up @@ -273,7 +275,7 @@ def __init__(
self.pk = pk_name
# Otherwise, assume first column
else:
if type(columns) == EnumType: # noqa: E721
if type(columns) == EnumMeta: # noqa: E721
self.pk = columns(0).name
elif isinstance(columns, list) and len(columns) > 0:
self.pk = columns[0]
Expand Down Expand Up @@ -457,7 +459,7 @@ def process_columns(self, columns: Union[List[str], str, Type[_IE]]) -> None:
self.columns = columns
elif isinstance(columns, str):
self.columns = [c.strip() for c in columns.split()]
elif type(columns) == EnumType: # noqa: E721
elif type(columns) == EnumMeta: # noqa: E721
# trailing _ can be used to avoid conflict with Enum members
self.columns = [c.name.rstrip("_") for c in columns]
else:
Expand Down

0 comments on commit 5597186

Please sign in to comment.