Skip to content

Commit

Permalink
fix to use List as a return type of the methods
Browse files Browse the repository at this point in the history
  • Loading branch information
okapies authored and oroulet committed Sep 10, 2023
1 parent 1347989 commit d3d5210
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
32 changes: 16 additions & 16 deletions asyncua/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def load_private_key(self, path: Path, password: Optional[Union[str, bytes
"""
self.user_private_key = await uacrypto.load_private_key(path, password, extension)

async def connect_and_get_server_endpoints(self) -> Sequence[ua.EndpointDescription]:
async def connect_and_get_server_endpoints(self) -> List[ua.EndpointDescription]:
"""
Connect, ask server for endpoints, and disconnect
"""
Expand All @@ -246,7 +246,7 @@ async def connect_and_get_server_endpoints(self) -> Sequence[ua.EndpointDescript
self.disconnect_socket()
return endpoints

async def connect_and_find_servers(self) -> Sequence[ua.ApplicationDescription]:
async def connect_and_find_servers(self) -> List[ua.ApplicationDescription]:
"""
Connect, ask server for a list of known servers, and disconnect
"""
Expand All @@ -262,7 +262,7 @@ async def connect_and_find_servers(self) -> Sequence[ua.ApplicationDescription]:
self.disconnect_socket()
return servers

async def connect_and_find_servers_on_network(self) -> Sequence[ua.FindServersOnNetworkResult]:
async def connect_and_find_servers_on_network(self) -> List[ua.FindServersOnNetworkResult]:
"""
Connect, ask server for a list of known servers on network, and disconnect
"""
Expand Down Expand Up @@ -382,7 +382,7 @@ async def open_secure_channel(self, renew: bool = False) -> None:
async def close_secure_channel(self):
return await self.uaclient.close_secure_channel()

async def get_endpoints(self) -> Sequence[ua.EndpointDescription]:
async def get_endpoints(self) -> List[ua.EndpointDescription]:
"""Get a list of OPC-UA endpoints."""

params = ua.GetEndpointsParameters()
Expand Down Expand Up @@ -427,7 +427,7 @@ async def unregister_server(self, server: "asyncua.server.Server", discovery_con
return await self.uaclient.unregister_server2(params)
return await self.uaclient.unregister_server(serv)

async def find_servers(self, uris: Optional[Iterable[str]] = None) -> Sequence[ua.ApplicationDescription]:
async def find_servers(self, uris: Optional[Iterable[str]] = None) -> List[ua.ApplicationDescription]:
"""
send a FindServer request to the server. The answer should be a list of
servers the server knows about
Expand All @@ -440,7 +440,7 @@ async def find_servers(self, uris: Optional[Iterable[str]] = None) -> Sequence[u
params.ServerUris = list(uris)
return await self.uaclient.find_servers(params)

async def find_servers_on_network(self) -> Sequence[ua.FindServersOnNetworkResult]:
async def find_servers_on_network(self) -> List[ua.FindServersOnNetworkResult]:
params = ua.FindServersOnNetworkParameters()
return await self.uaclient.find_servers_on_network(params)

Expand Down Expand Up @@ -757,7 +757,7 @@ def get_subscription_revised_params( # type: ignore
modified_params.RequestedLifetimeCount = results.RevisedLifetimeCount
return modified_params

async def delete_subscriptions(self, subscription_ids: Iterable[int]) -> Sequence[ua.StatusCode]:
async def delete_subscriptions(self, subscription_ids: Iterable[int]) -> List[ua.StatusCode]:
"""
Deletes the provided list of subscription_ids
"""
Expand All @@ -776,7 +776,7 @@ def get_keepalive_count(self, period: float) -> int:
period = period or 1000
return int((self.session_timeout / period) * 0.75)

async def get_namespace_array(self) -> Sequence[str]:
async def get_namespace_array(self) -> List[str]:
ns_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_NamespaceArray))
return await ns_node.read_value()

Expand All @@ -785,10 +785,10 @@ async def get_namespace_index(self, uri: str) -> int:
_logger.info("get_namespace_index %s %r", type(uries), uries)
return uries.index(uri)

async def delete_nodes(self, nodes: Iterable[Node], recursive=False) -> Tuple[Sequence[Node], Sequence[ua.StatusCode]]:
async def delete_nodes(self, nodes: Iterable[Node], recursive=False) -> Tuple[List[Node], List[ua.StatusCode]]:
return await delete_nodes(self.uaclient, nodes, recursive)

async def import_xml(self, path=None, xmlstring=None, strict_mode=True) -> Sequence[ua.NodeId]:
async def import_xml(self, path=None, xmlstring=None, strict_mode=True) -> List[ua.NodeId]:
"""
Import nodes defined in xml
"""
Expand Down Expand Up @@ -843,7 +843,7 @@ async def load_enums(self) -> Dict[str, Type]:
_logger.warning("Deprecated since spec 1.04, call load_data_type_definitions")
return await load_enums(self)

async def register_nodes(self, nodes: Iterable[Node]) -> Sequence[Node]:
async def register_nodes(self, nodes: Iterable[Node]) -> List[Node]:
"""
Register nodes for faster read and write access (if supported by server)
Rmw: This call modifies the nodeid of the nodes, the original nodeid is
Expand All @@ -868,21 +868,21 @@ async def unregister_nodes(self, nodes: Iterable[Node]) -> None:
node.nodeid = node.basenodeid
node.basenodeid = None

async def read_attributes(self, nodes: Iterable[Node], attr: ua.AttributeIds = ua.AttributeIds.Value) -> Sequence[ua.DataValue]:
async def read_attributes(self, nodes: Iterable[Node], attr: ua.AttributeIds = ua.AttributeIds.Value) -> List[ua.DataValue]:
"""
Read the attributes of multiple nodes.
"""
nodeids = [node.nodeid for node in nodes]
return await self.uaclient.read_attributes(nodeids, attr)

async def read_values(self, nodes: Iterable[Node]) -> Sequence[Any]:
async def read_values(self, nodes: Iterable[Node]) -> List[Any]:
"""
Read the value of multiple nodes in one ua call.
"""
res = await self.read_attributes(nodes, attr=ua.AttributeIds.Value)
return [r.Value.Value if r.Value else None for r in res]

async def write_values(self, nodes: Iterable[Node], values: Iterable[Any], raise_on_partial_error: bool = True) -> Sequence[ua.StatusCode]:
async def write_values(self, nodes: Iterable[Node], values: Iterable[Any], raise_on_partial_error: bool = True) -> List[ua.StatusCode]:
"""
Write values to multiple nodes in one ua call
"""
Expand All @@ -897,7 +897,7 @@ async def write_values(self, nodes: Iterable[Node], values: Iterable[Any], raise
get_values = read_values # legacy compatibility
set_values = write_values # legacy compatibility

async def browse_nodes(self, nodes: Iterable[Node]) -> Sequence[Tuple[Node, ua.BrowseResult]]:
async def browse_nodes(self, nodes: Iterable[Node]) -> List[Tuple[Node, ua.BrowseResult]]:
"""
Browses multiple nodes in one ua call
returns a List of Tuples(Node, BrowseResult)
Expand All @@ -915,7 +915,7 @@ async def browse_nodes(self, nodes: Iterable[Node]) -> Sequence[Tuple[Node, ua.B
results = await self.uaclient.browse(parameters)
return list(zip(nodes, results))

async def translate_browsepaths(self, starting_node: ua.NodeId, relative_paths: Iterable[Union[ua.RelativePath, str]]) -> Sequence[ua.BrowsePathResult]:
async def translate_browsepaths(self, starting_node: ua.NodeId, relative_paths: Iterable[Union[ua.RelativePath, str]]) -> List[ua.BrowsePathResult]:
bpaths = []
for p in relative_paths:
try:
Expand Down
32 changes: 16 additions & 16 deletions asyncua/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def load_data_type_definitions(self, node: Optional["SyncNode"] = None, overwrit
pass

@syncmethod
def get_namespace_array(self) -> Sequence[str]: # type: ignore[empty-body]
def get_namespace_array(self) -> List[str]: # type: ignore[empty-body]
pass

@syncmethod
Expand All @@ -313,7 +313,7 @@ def get_subscription_revised_params(self, params: ua.CreateSubscriptionParameter
return self.aio_obj.get_subscription_revised_params(params, results)

@syncmethod
def delete_subscriptions(self, subscription_ids: Iterable[int]) -> Sequence[ua.StatusCode]: # type: ignore[empty-body]
def delete_subscriptions(self, subscription_ids: Iterable[int]) -> List[ua.StatusCode]: # type: ignore[empty-body]
pass

@syncmethod
Expand All @@ -334,15 +334,15 @@ def get_server_node(self) -> "SyncNode":
return SyncNode(self.tloop, self.aio_obj.get_server_node())

@syncmethod
def connect_and_get_server_endpoints(self) -> Sequence[ua.EndpointDescription]: # type: ignore[empty-body]
def connect_and_get_server_endpoints(self) -> List[ua.EndpointDescription]: # type: ignore[empty-body]
pass

@syncmethod
def connect_and_find_servers(self) -> Sequence[ua.ApplicationDescription]: # type: ignore[empty-body]
def connect_and_find_servers(self) -> List[ua.ApplicationDescription]: # type: ignore[empty-body]
pass

@syncmethod
def connect_and_find_servers_on_network(self) -> Sequence[ua.FindServersOnNetworkResult]: # type: ignore[empty-body]
def connect_and_find_servers_on_network(self) -> List[ua.FindServersOnNetworkResult]: # type: ignore[empty-body]
pass

@syncmethod
Expand All @@ -358,7 +358,7 @@ def close_secure_channel(self) -> None:
pass

@syncmethod
def get_endpoints(self) -> Sequence[ua.EndpointDescription]: # type: ignore[empty-body]
def get_endpoints(self) -> List[ua.EndpointDescription]: # type: ignore[empty-body]
pass

@syncmethod
Expand All @@ -378,11 +378,11 @@ def unregister_server(
pass

@syncmethod
def find_servers(self, uris: Optional[Iterable[str]] = None) -> Sequence[ua.ApplicationDescription]: # type: ignore[empty-body]
def find_servers(self, uris: Optional[Iterable[str]] = None) -> List[ua.ApplicationDescription]: # type: ignore[empty-body]
pass

@syncmethod
def find_servers_on_network(self) -> Sequence[ua.FindServersOnNetworkResult]: # type: ignore[empty-body]
def find_servers_on_network(self) -> List[ua.FindServersOnNetworkResult]: # type: ignore[empty-body]
pass

@syncmethod
Expand Down Expand Up @@ -416,11 +416,11 @@ def get_keepalive_count(self, period: float) -> int:
return self.aio_obj.get_keepalive_count(period)

@syncmethod
def delete_nodes(self, nodes: Iterable["SyncNode"], recursive=False) -> Tuple[Sequence["SyncNode"], Sequence[ua.StatusCode]]: # type: ignore[empty-body]
def delete_nodes(self, nodes: Iterable["SyncNode"], recursive=False) -> Tuple[List["SyncNode"], List[ua.StatusCode]]: # type: ignore[empty-body]
pass

@syncmethod
def import_xml(self, path=None, xmlstring=None, strict_mode=True) -> Sequence[ua.NodeId]: # type: ignore[empty-body]
def import_xml(self, path=None, xmlstring=None, strict_mode=True) -> List[ua.NodeId]: # type: ignore[empty-body]
pass

@syncmethod
Expand All @@ -432,35 +432,35 @@ def register_namespace(self, uri: str) -> int: # type: ignore[empty-body]
pass

@syncmethod
def register_nodes(self, nodes: Iterable["SyncNode"]) -> Sequence["SyncNode"]: # type: ignore[empty-body]
def register_nodes(self, nodes: Iterable["SyncNode"]) -> List["SyncNode"]: # type: ignore[empty-body]
pass

@syncmethod
def unregister_nodes(self, nodes: Iterable["SyncNode"]): # type: ignore[empty-body]
pass

@syncmethod
def read_attributes(self, nodes: Iterable["SyncNode"], attr: ua.AttributeIds = ua.AttributeIds.Value) -> Sequence[ua.DataValue]: # type: ignore[empty-body]
def read_attributes(self, nodes: Iterable["SyncNode"], attr: ua.AttributeIds = ua.AttributeIds.Value) -> List[ua.DataValue]: # type: ignore[empty-body]
pass

@syncmethod
def read_values(self, nodes: Iterable["SyncNode"]) -> Sequence[Any]: # type: ignore[empty-body]
def read_values(self, nodes: Iterable["SyncNode"]) -> List[Any]: # type: ignore[empty-body]
pass

@syncmethod
def write_values(self, nodes: Iterable["SyncNode"], values: Iterable[Any], raise_on_partial_error: bool = True) -> Sequence[ua.StatusCode]: # type: ignore[empty-body]
def write_values(self, nodes: Iterable["SyncNode"], values: Iterable[Any], raise_on_partial_error: bool = True) -> List[ua.StatusCode]: # type: ignore[empty-body]
pass

@syncmethod
def browse_nodes(self, nodes: Iterable["SyncNode"]) -> Sequence[Tuple["SyncNode", ua.BrowseResult]]: # type: ignore[empty-body]
def browse_nodes(self, nodes: Iterable["SyncNode"]) -> List[Tuple["SyncNode", ua.BrowseResult]]: # type: ignore[empty-body]
pass

@syncmethod
def translate_browsepaths( # type: ignore[empty-body]
self,
starting_node: ua.NodeId,
relative_paths: Iterable[Union[ua.RelativePath, str]]
) -> Sequence[ua.BrowsePathResult]:
) -> List[ua.BrowsePathResult]:
pass

def __enter__(self):
Expand Down

0 comments on commit d3d5210

Please sign in to comment.