Skip to content

Commit 25e9240

Browse files
committed
Modernize Node type hints
1 parent f6e9bbb commit 25e9240

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

python/pyrogue/_Node.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import re
2121
import sys
2222
from collections import OrderedDict as odict
23-
from typing import Any, Callable, Iterable, List, Optional, Tuple
23+
from typing import Any, Callable, Iterable, Optional
2424

2525
import pyrogue as pr
2626

@@ -323,10 +323,10 @@ def __getattr__(self, name: str) -> Any:
323323
raise AttributeError('{} has no attribute {}'.format(self, name))
324324

325325

326-
def __dir__(self) -> List[str]:
326+
def __dir__(self) -> list[str]:
327327
return super().__dir__() + [k for k,v in self._nodes.items()]
328328

329-
def __reduce__(self) -> Tuple[Any, Tuple[dict]]:
329+
def __reduce__(self) -> tuple[Any, tuple[dict]]:
330330
attr = {}
331331

332332
attr['name'] = self._name
@@ -465,7 +465,7 @@ def addNodes(self, nodeClass: Callable[..., Any], number: int, stride: int, **kw
465465
self.add(nodeClass(name='{:s}[{:d}]'.format(name, i), offset=offset+(i*stride), **kwargs))
466466

467467
@property
468-
def nodeList(self) -> List[Any]:
468+
def nodeList(self) -> list[Any]:
469469
"""Return a recursive list of nodes."""
470470
lst = []
471471
for key,value in self._nodes.items():
@@ -521,7 +521,7 @@ def variablesByGroup(self, incGroups: Optional[list[str]] = None, excGroups: Opt
521521
return self.getNodes(typ=pr.BaseVariable,excTyp=pr.BaseCommand,incGroups=incGroups,excGroups=excGroups)
522522

523523
@property
524-
def variableList(self) -> List[Any]:
524+
def variableList(self) -> list[Any]:
525525
"""Return a recursive list of variables and commands."""
526526
lst = []
527527
for key,value in self.nodes.items():
@@ -550,7 +550,7 @@ def devicesByGroup(self, incGroups: Optional[list[str]] = None, excGroups: Optio
550550
return self.getNodes(pr.Device,incGroups=incGroups,excGroups=excGroups)
551551

552552
@property
553-
def deviceList(self) -> List[Any]:
553+
def deviceList(self) -> list[Any]:
554554
"""Return a recursive list of devices."""
555555
lst = []
556556
for key,value in self.nodes.items():
@@ -597,7 +597,7 @@ def isCommand(self) -> bool:
597597
"""Return True if this node is a command."""
598598
return self.isinstance(pr.BaseCommand)
599599

600-
def find(self, *, recurse: bool = True, typ: Optional[Any] = None, **kwargs: Any) -> List[Any]:
600+
def find(self, *, recurse: bool = True, typ: Optional[Any] = None, **kwargs: Any) -> list[Any]:
601601
"""
602602
Find all child nodes that are a base class of 'typ'
603603
and whose properties match all of the kwargs.
@@ -718,7 +718,7 @@ def _finishInit(self):
718718
def getYaml(
719719
self,
720720
readFirst: bool = False,
721-
modes: List[str] = ['RW','RO','WO'],
721+
modes: list[str] = ['RW','RO','WO'],
722722
incGroups: Optional[list[str]] = None,
723723
excGroups: Optional[list[str]] = ['Hidden'],
724724
recurse: bool = True,
@@ -750,7 +750,7 @@ def getYaml(
750750
def printYaml(
751751
self,
752752
readFirst: bool = False,
753-
modes: List[str] = ['RW','RO','WO'],
753+
modes: list[str] = ['RW','RO','WO'],
754754
incGroups: Optional[list[str]] = None,
755755
excGroups: Optional[list[str]] = ['Hidden'],
756756
recurse: bool = False,
@@ -862,7 +862,7 @@ def _setTimeout(self,timeout):
862862
"""
863863
pass
864864

865-
def nodeMatch(self, name: str) -> Tuple[List[Any], Optional[List[str]]]:
865+
def nodeMatch(self, name: str) -> tuple[list[Any], Optional[list[str]]]:
866866
"""Match a node name, including array-style accessors.
867867
868868
Parameters
@@ -902,7 +902,7 @@ def nodeMatch(self, name: str) -> Tuple[List[Any], Optional[List[str]]]:
902902
return _iterateDict(self._anodes[aname],keys),None
903903

904904

905-
def _iterateDict(d: dict, keys: List[str]) -> List[Any]:
905+
def _iterateDict(d: dict, keys: list[str]) -> list[Any]:
906906
"""Iterate into a nested dict using array-style keys."""
907907
retList = []
908908

@@ -943,7 +943,7 @@ def _iterateDict(d: dict, keys: List[str]) -> List[Any]:
943943
return retList
944944

945945

946-
def genBaseList(cls: Any) -> List[str]:
946+
def genBaseList(cls: Any) -> list[str]:
947947
"""Return a list of base class names for a class."""
948948
ret = [str(cls)]
949949

python/pyrogue/_RunControl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#-----------------------------------------------------------------------------
1515
import threading
1616
import time
17-
from typing import Any, Callable, Dict, Optional
17+
from typing import Any, Callable, Optional
1818

1919
import pyrogue as pr
2020

@@ -40,8 +40,8 @@ def __init__(
4040
self,
4141
*,
4242
hidden: bool = True,
43-
rates: Optional[Dict[int, str]] = None,
44-
states: Optional[Dict[int, str]] = None,
43+
rates: Optional[dict[int, str]] = None,
44+
states: Optional[dict[int, str]] = None,
4545
cmd: Optional[Callable[[], None]] = None,
4646
**kwargs: Any,
4747
) -> None:

python/pyrogue/_Variable.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import sys
2121
import threading
2222
import time
23-
from typing import Any, Callable, List, Optional
23+
from typing import Any, Callable, Optional
2424

2525
import numpy as np
2626
import pyrogue as pr
@@ -79,7 +79,7 @@ class VariableWaitClass(object):
7979
def __init__(
8080
self,
8181
varList: Any,
82-
testFunction: Optional[Callable[[List[Any]], bool]] = None,
82+
testFunction: Optional[Callable[[list[Any]], bool]] = None,
8383
timeout: float = 0,
8484
) -> None:
8585
self._values = odict()
@@ -142,7 +142,7 @@ def _check(self) -> bool:
142142

143143
def VariableWait(
144144
varList: Any,
145-
testFunction: Optional[Callable[[List[Any]], bool]] = None,
145+
testFunction: Optional[Callable[[list[Any]], bool]] = None,
146146
timeout: float = 0,
147147
) -> bool:
148148
"""

0 commit comments

Comments
 (0)