From 7934fe4c2698202725b8be87e4a4d1b98949a3a2 Mon Sep 17 00:00:00 2001 From: "Davin K. Tanabe" Date: Tue, 20 Dec 2022 14:16:49 -0500 Subject: [PATCH] python: Better support for interfaces. --- VERSION | 2 +- pyproject.toml | 2 +- python/dazl/__init__.py | 2 +- python/dazl/damlast/daml_lf_1.py | 4 ++-- python/dazl/damlast/pb_parse.py | 2 +- python/dazl/protocols/v1/pb_parse_metadata.py | 6 ++++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/VERSION b/VERSION index 70742ebd..0cbdb604 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.10.2 +7.10.3 diff --git a/pyproject.toml b/pyproject.toml index 52a9cbcd..e18ee32e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [tool.poetry] name = "dazl" -version = "7.10.2" +version = "7.10.3" description = "high-level Ledger API client for Daml ledgers" license = "Apache-2.0" authors = ["Davin K. Tanabe "] diff --git a/python/dazl/__init__.py b/python/dazl/__init__.py index 78907f38..f4096a50 100644 --- a/python/dazl/__init__.py +++ b/python/dazl/__init__.py @@ -73,4 +73,4 @@ pass -__version__ = "7.10.2" +__version__ = "7.10.3" diff --git a/python/dazl/damlast/daml_lf_1.py b/python/dazl/damlast/daml_lf_1.py index 48bcc6ef..b3a30af8 100644 --- a/python/dazl/damlast/daml_lf_1.py +++ b/python/dazl/damlast/daml_lf_1.py @@ -1808,9 +1808,9 @@ class ExerciseInterface: interface: TypeConName cid: Expr arg: Expr - guard: Expr + guard: Optional[Expr] - def __init__(self, interface: TypeConName, cid: Expr, arg: Expr, guard: Expr): + def __init__(self, interface: TypeConName, cid: Expr, arg: Expr, guard: Optional[Expr]): self.interface = interface self.cid = cid self.arg = arg diff --git a/python/dazl/damlast/pb_parse.py b/python/dazl/damlast/pb_parse.py index 6bf38744..cbc7d2fb 100644 --- a/python/dazl/damlast/pb_parse.py +++ b/python/dazl/damlast/pb_parse.py @@ -730,7 +730,7 @@ def parse_Update_ExerciseInterface( interface=self.parse_TypeConName(pb.interface), cid=self.parse_Expr(pb.cid), arg=self.parse_Expr(pb.arg), - guard=self.parse_Expr(pb.guard), + guard=self.parse_Expr(pb.guard) if pb.HasField("guard") else None, ) def parse_Update_FetchInterface( diff --git a/python/dazl/protocols/v1/pb_parse_metadata.py b/python/dazl/protocols/v1/pb_parse_metadata.py index 6a322a9a..e2c75055 100644 --- a/python/dazl/protocols/v1/pb_parse_metadata.py +++ b/python/dazl/protocols/v1/pb_parse_metadata.py @@ -276,7 +276,7 @@ def _parse_daml_metadata_pb(archive: "Archive") -> "PackageStore": tt = create_data_type(current_module, dt) if isinstance(tt, (RecordType, VariantType, EnumType)) and tt.name is not None: psb.add_type(tt.name.con, tt) - else: + elif tt is not None: LOG.warning("Unexpected non-complex type will be ignored: %r", tt) for template_pb in module.templates: @@ -325,7 +325,7 @@ def _parse_daml_metadata_pb(archive: "Archive") -> "PackageStore": # noinspection PyDeprecation def create_data_type( current_module_ref: "ModuleRef", dt: "DefDataType" -) -> "Union[RecordType, VariantType, EnumType, ScalarType]": +) -> "Union[None, RecordType, VariantType, EnumType, ScalarType]": warnings.warn( "create_data_type is deprecated; there is no replacement.", DeprecationWarning, stacklevel=2 ) @@ -357,5 +357,7 @@ def create_data_type( return VariantType(NamedArgumentList(d.items()), tt, type_vars) elif dt.enum is not None: return EnumType(tt, dt.enum.constructors) + elif dt.interface is not None: + return None else: return SCALAR_TYPE_UNIT