Skip to content

Commit

Permalink
[cdd/sqlalchemy/utils/emit_utils.py] Use ARRAY for list and `tupl…
Browse files Browse the repository at this point in the history
…e` out of SQLalchemy
  • Loading branch information
SamuelMarks committed Feb 17, 2024
1 parent 467949e commit c2c8ade
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cdd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from logging import getLogger as get_logger

__author__ = "Samuel Marks" # type: str
__version__ = "0.0.99rc33" # type: str
__version__ = "0.0.99rc34" # type: str
__description__ = (
"Open API to/fro routes, models, and tests. "
"Convert between docstrings, classes, methods, argparse, pydantic, and SQLalchemy."
Expand Down
2 changes: 1 addition & 1 deletion cdd/shared/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
total=False,
)

__all__ = ["IntermediateRepr", "Internal"] # type: list[str]
__all__ = ["IntermediateRepr", "Internal", "ParamVal"] # type: list[str]
3 changes: 3 additions & 0 deletions cdd/sqlalchemy/utils/emit_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,9 @@ def sqlalchemy_table_to_class(table_expr_ass):
"string": "String",
"int64": "BigInteger",
"Optional[dict]": "JSON",
# TODO: Infer type from default fallback to LargeBinary,
"list": "ARRAY({})".format("LargeBinary"),
"Tuple": "ARRAY({}, as_tuple=True)".format("LargeBinary"),
}
)

Expand Down
4 changes: 2 additions & 2 deletions cdd/sqlalchemy/utils/shared_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def update_args_infer_typ_sqlalchemy(_param, args, name, nullable, x_typ_sql):
args.append(
Name(
(
cdd.sqlalchemy.utils.emit_utils.typ2column_type.get(right, right)
if left in cdd.sqlalchemy.utils.emit_utils.typ2column_type
cdd.sqlalchemy.utils.emit_utils.typ2column_type[right]
if right in cdd.sqlalchemy.utils.emit_utils.typ2column_type
else cdd.sqlalchemy.utils.emit_utils.typ2column_type.get(left, left)
),
Load(),
Expand Down
8 changes: 8 additions & 0 deletions cdd/tests/test_docstring/test_parse_docstring_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import cdd.shared.docstring_parsers
from cdd.docstring.utils.parse_utils import parse_adhoc_doc_for_typ
from cdd.shared.pure_utils import pp
from cdd.tests.mocks.docstrings import docstring_google_keras_tensorboard_return_str
from cdd.tests.mocks.ir import class_google_keras_tensorboard_ir
from cdd.tests.utils_for_tests import unittest_main
Expand All @@ -31,6 +32,13 @@ def test_parse_adhoc_doc_for_typ(self) -> None:
"""
Test that `parse_adhoc_doc_for_typ` works for various found-in-wild Keras variants
"""
pp(
parse_adhoc_doc_for_typ(
"Dictionary of `{str: object}` pairs, where the `str` key is the object name.",
name="",
default_is_none=False,
)
)
deque(
map(
lambda output_input: self.assertEqual(
Expand Down

0 comments on commit c2c8ade

Please sign in to comment.