Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
da-tanabe committed Mar 12, 2021
1 parent 9371f81 commit 4a439b4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
32 changes: 18 additions & 14 deletions python/dazl/ledger/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
.. autoclass:: ExerciseByKeyCommand
:members:
"""
from typing import AbstractSet, Any, Collection, Mapping, NoReturn, Optional, Sequence, Union
from __future__ import annotations
from typing import AbstractSet, Any, Collection, Mapping, NoReturn, Optional, Sequence, Union, TYPE_CHECKING

from ..damlast.daml_lf_1 import TypeConName
from ..damlast.lookup import parse_type_con_name
Expand All @@ -49,7 +50,7 @@ class Command:
Base class for write-side commands.
"""

def __setattr__(self, key, value) -> "NoReturn":
def __setattr__(self, key, value) -> NoReturn:
"""
Raise :class:`AttributeError`; instances of this class are immutable.
"""
Expand All @@ -62,8 +63,11 @@ class CreateCommand(Command):
"""

__slots__ = ("_template_id", "_payload")
if TYPE_CHECKING:
_template_id: TypeConName
_payload: ContractData

def __init__(self, template_id: "Union[str, TypeConName]", payload: "ContractData"):
def __init__(self, template_id: Union[str, TypeConName], payload: ContractData):
"""
Initialize a :class:`CreateCommand`.
Expand All @@ -76,14 +80,14 @@ def __init__(self, template_id: "Union[str, TypeConName]", payload: "ContractDat
object.__setattr__(self, "_payload", payload)

@property
def template_id(self) -> "TypeConName":
def template_id(self) -> TypeConName:
"""
Return the template of the contract to be created.
"""
return self._template_id

@property
def payload(self) -> "Mapping[str, Any]":
def payload(self) -> Mapping[str, Any]:
"""
Return the template arguments for the contract to be created.
"""
Expand All @@ -105,10 +109,10 @@ class CreateAndExerciseCommand(Command):

def __init__(
self,
template_id: "Union[str, TypeConName]",
payload: "ContractData",
template_id: Union[str, TypeConName],
payload: ContractData,
choice: str,
argument: "Optional[Any]" = None,
argument: Optional[Any] = None,
):
"""
Initialize a :class:`CreateAndExerciseCommand`.
Expand Down Expand Up @@ -420,12 +424,12 @@ def __repr__(self):

class PartyInfo:
__slots__ = "_party", "_display_name", "_is_local"
if TYPE_CHECKING:
_party: Party
_display_name: str
_is_local: bool

_party: "Party"
_display_name: str
_is_local: bool

def __init__(self, party: "Party", display_name: str, is_local: bool):
def __init__(self, party: Party, display_name: str, is_local: bool):
object.__setattr__(self, "_party", party)
object.__setattr__(self, "_display_name", display_name)
object.__setattr__(self, "_is_local", is_local)
Expand All @@ -443,7 +447,7 @@ def is_local(self) -> bool:
return self._is_local


def validate_template_id(value: "Union[str, TypeConName]") -> "TypeConName":
def validate_template_id(value: Union[str, TypeConName]) -> TypeConName:
if isinstance(value, TypeConName):
return value
else:
Expand Down
3 changes: 0 additions & 3 deletions python/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[mypy]

[mypy-grpc.*]
ignore_missing_imports = True

[mypy-google.protobuf.pyext.*]
ignore_missing_imports = True

Expand Down
19 changes: 18 additions & 1 deletion python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ setuptools = "==40.8.0"
sphinx = "*"
sphinx-markdown-builder = "^0.5.1"
watchdog = "*"
grpc-stubs = "^1.24.5"

[tool.poetry.extras]
oauth = ["google-auth", "oauthlib"]
Expand Down

0 comments on commit 4a439b4

Please sign in to comment.