Skip to content

Commit f5429cd

Browse files
committed
Work around StrEnum not being in python until 3.11
1 parent 7c9ccb7 commit f5429cd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ readme = "README.md"
99
license = { text = "Apache-2" }
1010
requires-python = ">= 3.9"
1111
dynamic = ["version"]
12-
dependencies = ["lark[interegular]", "numpy", "convertdate"]
12+
dependencies = ["lark[interegular]", "numpy", "convertdate", "strenum; python_version > '3.11'"]
1313
authors = [
1414
{ name = "Rebecca Sutton Koeser" },
1515
{ name = "Cole Crawford" },

src/undate/undate.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import datetime
22
import re
3-
from enum import StrEnum, auto
3+
4+
from enum import auto
5+
6+
try:
7+
# StrEnum was only added in python 3.11
8+
from enum import StrEnum
9+
except ImportError:
10+
# for python 3.10 or earlier, use third-party package
11+
from strenum import StrEnum # type: ignore
412

513
# Pre 3.10 requires Union for multiple types, e.g. Union[int, None] instead of int | None
614
from typing import Dict, Optional, Union

0 commit comments

Comments
 (0)