Skip to content

Commit

Permalink
[cdd/emit/utils/sqlalchemy_utils.py] Ensure support for Python 3.6 an…
Browse files Browse the repository at this point in the history
…d 3.7
  • Loading branch information
SamuelMarks committed Jan 9, 2023
1 parent 13ad65f commit 72a0d60
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cdd/emit/utils/sqlalchemy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Expr,
FunctionDef,
ImportFrom,
Index,
Load,
Module,
Name,
Expand All @@ -36,6 +35,7 @@
sqlalchemy_top_level_imports,
)
from cdd.pure_utils import (
PY_GTE_3_8,
find_module_filepath,
none_types,
rpartial,
Expand Down Expand Up @@ -200,13 +200,13 @@ def update_args_infer_typ_sqlalchemy(_param, args, name, nullable, x_typ_sql):
elif _param.get("typ").startswith("Union["):
# Hack to remove the union type. Enum parse seems to be incorrect?
union_typ = ast.parse(_param["typ"]).body[0]
assert (
isinstance(union_typ.value, Subscript)
and isinstance(union_typ.value.slice, Index)
and isinstance(union_typ.value.slice.value, Tuple)
assert isinstance(union_typ.value, Subscript)
union_typ_tuple = (
union_typ.value.slice if PY_GTE_3_8 else union_typ.value.slice.value
)
assert len(union_typ.value.slice.value.elts) == 2
left, right = map(attrgetter("id"), union_typ.value.slice.value.elts)
assert isinstance(union_typ_tuple, Tuple)
assert len(union_typ_tuple.elts) == 2
left, right = map(attrgetter("id"), union_typ_tuple.elts)
args.append(
Name(
typ2column_type.get(right, right)
Expand Down

0 comments on commit 72a0d60

Please sign in to comment.