You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by hu...@apache.org on 2022/11/14 18:26:14 UTC
[plc4x] branch develop updated: fix(plc4py): Replace builtin types (list and dict) with class from the typing package.
This is an automated email from the ASF dual-hosted git repository.
hutcheb pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 135452d103 fix(plc4py): Replace builtin types (list and dict) with class from the typing package.
135452d103 is described below
commit 135452d103495202f363ebbe40a415d2881002f8
Author: Ben Hutcheson <be...@gmail.com>
AuthorDate: Mon Nov 14 12:25:26 2022 -0600
fix(plc4py): Replace builtin types (list and dict) with class from the typing package.
---
sandbox/plc4py/plc4py/PlcDriverManager.py | 4 ++--
sandbox/plc4py/plc4py/api/messages/PlcRequest.py | 4 ++--
sandbox/plc4py/plc4py/api/messages/PlcResponse.py | 6 +++---
sandbox/plc4py/plc4py/drivers/mock/MockConnection.py | 4 ++--
sandbox/plc4py/plc4py/drivers/mock/MockReadRequestBuilder.py | 6 +++---
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/sandbox/plc4py/plc4py/PlcDriverManager.py b/sandbox/plc4py/plc4py/PlcDriverManager.py
index 1fba493d93..fc26b1c664 100644
--- a/sandbox/plc4py/plc4py/PlcDriverManager.py
+++ b/sandbox/plc4py/plc4py/PlcDriverManager.py
@@ -20,7 +20,7 @@
import logging
from contextlib import asynccontextmanager
from dataclasses import dataclass, field
-from typing import Type, AsyncIterator
+from typing import Type, AsyncIterator, List
from pluggy import PluginManager # type: ignore
from plc4py.api.PlcConnection import PlcConnection
@@ -78,7 +78,7 @@ class PlcDriverManager:
protocol_code = get_protocol_code(url)
return await self._driverMap[protocol_code]().get_connection(url)
- def list_drivers(self) -> list[str]:
+ def list_drivers(self) -> List[str]:
"""
Returns the codes of the drivers which are currently registered at the PlcDriverManager
:return: Set of driver codes for all drivers registered
diff --git a/sandbox/plc4py/plc4py/api/messages/PlcRequest.py b/sandbox/plc4py/plc4py/api/messages/PlcRequest.py
index 3bd2b5e977..6bca13c14f 100644
--- a/sandbox/plc4py/plc4py/api/messages/PlcRequest.py
+++ b/sandbox/plc4py/plc4py/api/messages/PlcRequest.py
@@ -18,7 +18,7 @@
#
from abc import abstractmethod
from dataclasses import dataclass, field
-from typing import Union
+from typing import Union, List
from plc4py.api.messages.PlcField import PlcField
from plc4py.api.messages.PlcMessage import PlcMessage
@@ -33,7 +33,7 @@ class PlcRequest(PlcMessage):
@dataclass
class PlcFieldRequest(PlcRequest):
- fields: list[PlcField] = field(default_factory=lambda: [])
+ fields: List[PlcField] = field(default_factory=lambda: [])
@property
def field_names(self):
diff --git a/sandbox/plc4py/plc4py/api/messages/PlcResponse.py b/sandbox/plc4py/plc4py/api/messages/PlcResponse.py
index 199815bcc9..79eef53f82 100644
--- a/sandbox/plc4py/plc4py/api/messages/PlcResponse.py
+++ b/sandbox/plc4py/plc4py/api/messages/PlcResponse.py
@@ -17,7 +17,7 @@
# under the License.
#
from dataclasses import dataclass
-from typing import cast
+from typing import cast, List, Dict
from plc4py.api.messages.PlcField import PlcField
from plc4py.api.messages.PlcMessage import PlcMessage
@@ -37,7 +37,7 @@ class PlcResponse(PlcMessage):
@dataclass
class PlcFieldResponse(PlcResponse):
- fields: list[PlcField]
+ fields: List[PlcField]
@property
def field_names(self):
@@ -53,7 +53,7 @@ class PlcReadResponse(PlcFieldResponse):
Response to a {@link PlcReadRequest}.
"""
- values: dict[str, list[ResponseItem[PlcValue]]]
+ values: Dict[str, List[ResponseItem[PlcValue]]]
def get_plc_value(self, name: str, index: int = 0) -> PlcValue:
return self.values[name][index].value
diff --git a/sandbox/plc4py/plc4py/drivers/mock/MockConnection.py b/sandbox/plc4py/plc4py/drivers/mock/MockConnection.py
index 38559bb988..16f809542a 100644
--- a/sandbox/plc4py/plc4py/drivers/mock/MockConnection.py
+++ b/sandbox/plc4py/plc4py/drivers/mock/MockConnection.py
@@ -20,7 +20,7 @@
import asyncio
import logging
from dataclasses import dataclass, field
-from typing import Awaitable, Type
+from typing import Awaitable, Type, List
import plc4py
@@ -75,7 +75,7 @@ class MockPlcFieldHandler:
class MockDevice:
fields: dict[str, PlcValue] = field(default_factory=lambda: {})
- def read(self, field: str) -> list[ResponseItem[PlcValue]]:
+ def read(self, field: str) -> List[ResponseItem[PlcValue]]:
"""
Reads one field from the Mock Device
"""
diff --git a/sandbox/plc4py/plc4py/drivers/mock/MockReadRequestBuilder.py b/sandbox/plc4py/plc4py/drivers/mock/MockReadRequestBuilder.py
index 904e33e2b2..f496398159 100644
--- a/sandbox/plc4py/plc4py/drivers/mock/MockReadRequestBuilder.py
+++ b/sandbox/plc4py/plc4py/drivers/mock/MockReadRequestBuilder.py
@@ -18,7 +18,7 @@
#
from dataclasses import dataclass, field
-from typing import Union
+from typing import Union, List
from plc4py.api.messages.PlcMessage import PlcMessage
from plc4py.api.messages.PlcRequest import (
@@ -35,13 +35,13 @@ class MockPlcReadResponse(PlcReadResponse):
class MockPlcReadRequest(PlcReadRequest):
- def __init__(self, fields: list[PlcField] = []):
+ def __init__(self, fields: List[PlcField] = []):
super().__init__(fields)
@dataclass
class MockReadRequestBuilder(ReadRequestBuilder):
- items: list[PlcField] = field(default_factory=lambda: [])
+ items: List[PlcField] = field(default_factory=lambda: [])
def build(self) -> PlcReadRequest:
return MockPlcReadRequest(self.items)