Skip to content

Commit

Permalink
Work around StrEnum not being in python until 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Nov 26, 2024
1 parent 7c9ccb7 commit f5429cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ readme = "README.md"
license = { text = "Apache-2" }
requires-python = ">= 3.9"
dynamic = ["version"]
dependencies = ["lark[interegular]", "numpy", "convertdate"]
dependencies = ["lark[interegular]", "numpy", "convertdate", "strenum; python_version > '3.11'"]
authors = [
{ name = "Rebecca Sutton Koeser" },
{ name = "Cole Crawford" },
Expand Down
10 changes: 9 additions & 1 deletion src/undate/undate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import datetime
import re
from enum import StrEnum, auto

from enum import auto

try:
# StrEnum was only added in python 3.11
from enum import StrEnum
except ImportError:
# for python 3.10 or earlier, use third-party package
from strenum import StrEnum # type: ignore

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

0 comments on commit f5429cd

Please sign in to comment.