File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 15
15
16
16
from enum import Enum
17
17
from typing import Set
18
+ from openlcb .nodeid import NodeID
18
19
from openlcb .pip import PIP
19
20
from openlcb .snip import SNIP
20
21
from openlcb .localeventstore import LocalEventStore
@@ -40,11 +41,12 @@ class Node:
40
41
events (LocalEventStore): The store for local events associated
41
42
with the node.
42
43
"""
43
- def __init__ (self , nodeID , snip : SNIP = None , pipSet : Set [PIP ] = None ):
44
- self .id = nodeID
45
- self .snip = snip
44
+ def __init__ (self , nodeID : NodeID , snip : SNIP = None ,
45
+ pipSet : Set [PIP ] = None ):
46
+ self .id : NodeID = nodeID
47
+ self .snip : SNIP = snip
46
48
if snip is None : self .snip = SNIP ()
47
- self .pipSet = pipSet
49
+ self .pipSet : Set [ PIP ] = pipSet
48
50
if pipSet is None : self .pipSet = set ([])
49
51
self .state = Node .State .Uninitialized
50
52
self .events = LocalEventStore ()
Original file line number Diff line number Diff line change 1
1
from typing import (
2
+ Dict ,
2
3
List , # in case list doesn't support `[` in this Python version
3
4
Union , # in case `|` doesn't support 'type' in this Python version
4
5
)
@@ -18,7 +19,7 @@ class NodeStore :
18
19
'''
19
20
20
21
def __init__ (self ) :
21
- self .byIdMap : dict = {}
22
+ self .byIdMap : Dict [ NodeID , Node ] = {}
22
23
self .nodes : List [Node ] = []
23
24
self .processors : List [Processor ] = []
24
25
@@ -34,10 +35,10 @@ def store(self, node: Node) :
34
35
self .nodes .sort (key = lambda x : x .snip .userProvidedNodeName ,
35
36
reverse = True )
36
37
37
- def isPresent (self , nodeID ) :
38
+ def isPresent (self , nodeID : NodeID ) -> bool :
38
39
return self .byIdMap .get (nodeID ) is not None
39
40
40
- def asArray (self ) :
41
+ def asArray (self ) -> List [ Node ] :
41
42
return [self .byIdMap [i ] for i in self .byIdMap ]
42
43
43
44
# Retrieve a Node's content from the store
You can’t perform that action at this time.
0 commit comments