Skip to content

Commit

Permalink
chore: Add typehints for the optional shelf file
Browse files Browse the repository at this point in the history
to clarify its intended usage.
  • Loading branch information
AiyionPrime authored and oroulet committed Feb 16, 2024
1 parent f41b67e commit cf2bd66
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion asyncua/server/address_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
from functools import partial
from pathlib import Path
from typing import TYPE_CHECKING, Optional

if TYPE_CHECKING:
Expand Down Expand Up @@ -697,7 +698,7 @@ def load(self, path):
with open(path, 'rb') as f:
self._nodes = pickle.load(f)

def make_aspace_shelf(self, path):
def make_aspace_shelf(self, path: Path):
"""
Make a shelf for containing the nodes from the standard address space; this is typically only done on first
start of the server. Subsequent server starts will load the shelf, nodes are then moved to a cache
Expand Down
4 changes: 2 additions & 2 deletions asyncua/server/internal_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, user_manager: UserManager = None):
self.match_discovery_source_ip: bool = True
self.supported_tokens = []

async def init(self, shelffile=None):
async def init(self, shelffile: Optional[Path] = None):
await self.load_standard_address_space(shelffile)
await self._address_space_fixes()
await self.setup_nodes()
Expand Down Expand Up @@ -135,7 +135,7 @@ async def setup_nodes(self):
result = await self.isession.write(params)
result[0].check()

async def load_standard_address_space(self, shelf_file=None):
async def load_standard_address_space(self, shelf_file: Optional[Path] = None):
if shelf_file:
is_file = await asyncio.get_running_loop().run_in_executor(
None, Path.is_file, shelf_file
Expand Down
2 changes: 1 addition & 1 deletion asyncua/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(self, iserver: InternalServer = None, user_manager=None):
max_message_size=max_msg_sz
)

async def init(self, shelf_file=None):
async def init(self, shelf_file: Optional[Path] = None):
await self.iserver.init(shelf_file)
# setup some expected values
await self.set_application_uri(self._application_uri)
Expand Down
2 changes: 1 addition & 1 deletion asyncua/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ class Server:
waits for an async call to return. defualt is 120s and hopefully should fit most applications
"""

def __init__(self, shelf_file=None, tloop=None, sync_wrapper_timeout: Optional[float] = 120,):
def __init__(self, shelf_file: Optional[Path] = None, tloop=None, sync_wrapper_timeout: Optional[float] = 120,):
self.tloop = tloop
self.close_tloop = False
if not self.tloop:
Expand Down

0 comments on commit cf2bd66

Please sign in to comment.