Commit 066c61eb authored by Yuta Okamoto's avatar Yuta Okamoto Committed by oroulet

add type hints to Subscription

parent 39e07108
......@@ -14,7 +14,7 @@ from ..common.xmlimporter import XmlImporter
from ..common.xmlexporter import XmlExporter
from ..common.node import Node
from ..common.manage_nodes import delete_nodes
from ..common.subscription import SubHandler, Subscription
from ..common.subscription import Subscription, SubscriptionHandler
from ..common.shortcuts import Shortcuts
from ..common.structures import load_type_definitions, load_enums
from ..common.structures104 import load_data_type_definitions
......@@ -719,7 +719,7 @@ class Client:
return Node(self.uaclient, nodeid)
async def create_subscription(
self, period: Union[ua.CreateSubscriptionParameters, float], handler: SubHandler, publishing: bool = True
self, period: Union[ua.CreateSubscriptionParameters, float], handler: SubscriptionHandler, publishing: bool = True
) -> Subscription:
"""
Create a subscription.
......
This diff is collapsed.
from __future__ import annotations
import asyncio
import logging
from datetime import timedelta
from datetime import datetime
from asyncua import ua
from ..common.subscription import Subscription, SubHandler
from asyncua.common import subscription
from asyncua.common.subscription import Subscription, SubscriptionHandler
from ..common.utils import Buffer
......@@ -213,8 +216,8 @@ class HistoryDict(HistoryStorageInterface):
pass
class SubHandler(SubHandler): # type: ignore
def __init__(self, storage):
class SubHandler(subscription.SubHandler):
def __init__(self, storage: HistoryStorageInterface):
self.storage = storage
def datachange_notification(self, node, val, data):
......@@ -240,7 +243,7 @@ class HistoryManager:
"""
self.storage = storage
async def _create_subscription(self, handler):
async def _create_subscription(self, handler: SubscriptionHandler):
params = ua.CreateSubscriptionParameters()
params.RequestedPublishingInterval = 10
params.RequestedLifetimeCount = 3000
......
......@@ -59,7 +59,7 @@ class InternalSession(AbstractSession):
def is_activated(self) -> bool:
return self.state == SessionState.Activated
async def create_session(self, params: ua.CreateSessionParameters, sockname: Optional[Tuple[str, int]]=None):
async def create_session(self, params: ua.CreateSessionParameters, sockname: Optional[Tuple[str, int]] = None):
self.logger.info('Create session request')
result = ua.CreateSessionResult()
result.SessionId = self.session_id
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment