Skip to content

Commit 9d0223e

Browse files
committed
TL: better completion for ParamClass instances
1 parent c38e74a commit 9d0223e

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

blockops/utils/params.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Contains utility classes and wrapper to list and check parameters.
77
"""
88
import inspect
9-
from typing import Hashable, Callable
9+
from typing import Hashable
1010
import copy
1111
import numpy as np
1212

@@ -30,18 +30,18 @@ def __init__(self, name, value, reason):
3030

3131
class Parameter(object):
3232
"""Base class to describe a parameter"""
33-
33+
3434
def __init__(self, latexName=None):
35-
35+
3636
self.name = None
3737
self.docs = None
3838
self.default = None
3939
self.value = None
40-
40+
4141
self._latexName = latexName
4242
self._uniqueID = None
43-
44-
43+
44+
4545
@property
4646
def latexName(self):
4747
if self._latexName is None:
@@ -51,20 +51,20 @@ def latexName(self):
5151
return f"{self.name[0].upper() + self.name[1:]}"
5252
else:
5353
return self._latexName
54-
55-
54+
55+
5656
@property
5757
def uniqueID(self):
5858
if self._uniqueID is None:
5959
return self.name
6060
else:
6161
return self._uniqueID
62-
62+
6363
@uniqueID.setter
6464
def uniqueID(self, value):
6565
self._uniqueID = value
66-
67-
66+
67+
6868
def error(self, value, reason):
6969
reason += f" ({self.pType})"
7070
raise ParamError(self.name, value, reason)
@@ -149,7 +149,7 @@ def extractParamDocs(cls, *names):
149149
# Main class decorator to be applied on ParamClass subclasses
150150
# -----------------------------------------------------------------------------
151151

152-
def setParams(**kwargs) -> Callable[[ParamClass], ParamClass]:
152+
def setParams(**kwargs):
153153
"""Class decorator to set the parameter types"""
154154

155155
def wrapper(cls):
@@ -204,7 +204,7 @@ class PositiveInteger(Parameter):
204204
def __init__(self, strict=True, latexName=None):
205205
self.strict = strict
206206
super().__init__(latexName)
207-
207+
208208

209209
def check(self, value):
210210
try:
@@ -228,7 +228,7 @@ class ScalarNumber(Parameter):
228228
def __init__(self, positive=False, latexName=None):
229229
self.positive = positive
230230
super().__init__(latexName)
231-
231+
232232

233233
def check(self, value):
234234
dtype = float if self.positive else complex
@@ -269,7 +269,7 @@ def __init__(self, *choices, latexName=None):
269269
self.pTypes = [c for c in choices if isinstance(c, Parameter)]
270270
self.choices = [c for c in choices if not isinstance(c, Parameter)]
271271
super().__init__(latexName)
272-
272+
273273

274274
def check(self, value):
275275
choices = [c for c in self.choices]

0 commit comments

Comments
 (0)