kisa-utils 0.37.9__py3-none-any.whl → 0.37.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kisa_utils/functionUtils.py +9 -4
- {kisa_utils-0.37.9.dist-info → kisa_utils-0.37.10.dist-info}/METADATA +1 -1
- {kisa_utils-0.37.9.dist-info → kisa_utils-0.37.10.dist-info}/RECORD +5 -5
- {kisa_utils-0.37.9.dist-info → kisa_utils-0.37.10.dist-info}/WHEEL +0 -0
- {kisa_utils-0.37.9.dist-info → kisa_utils-0.37.10.dist-info}/top_level.txt +0 -0
kisa_utils/functionUtils.py
CHANGED
|
@@ -59,7 +59,12 @@ def protected(func:Callable) -> Callable:
|
|
|
59
59
|
return func(*args, **kwargs)
|
|
60
60
|
return wrapper
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
# ------------------------------------------------------------------------------
|
|
63
|
+
from typing import ParamSpec, TypeVar
|
|
64
|
+
P = ParamSpec('P')
|
|
65
|
+
T = TypeVar('T')
|
|
66
|
+
|
|
67
|
+
def enforceRequirements(func:Callable[P, T]) -> Callable[P, T]:
|
|
63
68
|
'''
|
|
64
69
|
force decorated function to observe the following
|
|
65
70
|
- have type hints for all `args`, and `kwargs` as well as the `return` type-hint
|
|
@@ -68,9 +73,9 @@ def enforceRequirements(func:Callable) -> Callable:
|
|
|
68
73
|
- ensure all arguments are given values of the right type when the function is called
|
|
69
74
|
- return the right data-type as specified by the return type-hint when invoked
|
|
70
75
|
'''
|
|
76
|
+
signature = inspect.signature(func)
|
|
77
|
+
typeHints = func.__annotations__
|
|
71
78
|
if 1:
|
|
72
|
-
signature = inspect.signature(func)
|
|
73
|
-
typeHints = func.__annotations__
|
|
74
79
|
parameters = signature.parameters
|
|
75
80
|
|
|
76
81
|
if not (func.__doc__ and func.__doc__.strip()):
|
|
@@ -118,7 +123,7 @@ def enforceRequirements(func:Callable) -> Callable:
|
|
|
118
123
|
# print(registeredArgs, registeredKwargs)
|
|
119
124
|
|
|
120
125
|
@wraps(func)
|
|
121
|
-
def w(*args, **kwargs):
|
|
126
|
+
def w(*args:P.args, **kwargs:P.kwargs):
|
|
122
127
|
for index, arg in enumerate(args):
|
|
123
128
|
if registeredArgs[index][0] in ['self']: continue
|
|
124
129
|
if not (resp := validateWithResponse(arg, registeredArgs[index][1])):
|
|
@@ -7,7 +7,7 @@ kisa_utils/db.py,sha256=gU6BSBSglrndUMhmhOmIEVNXKSiRV6vqf2pskJKYmlQ,44463
|
|
|
7
7
|
kisa_utils/encryption.py,sha256=nFzNpzWV_D9uSEq4FsgCnlS7FQtqWP9fvM_81rsfcLo,4218
|
|
8
8
|
kisa_utils/enqueue.py,sha256=VIliaMvw4MUdOqts0dXdZCYNxs-QrOVjIRAR3scGrRM,11786
|
|
9
9
|
kisa_utils/figures.py,sha256=pYIpQzu1OXRSsY1d98GhgPifnIRmgl-r7S32ai-Ms0c,3731
|
|
10
|
-
kisa_utils/functionUtils.py,sha256=
|
|
10
|
+
kisa_utils/functionUtils.py,sha256=5Xu-ixV5S7sVBrr1ZhIOrLPVVCbvU-EOAX7i46Mzwdc,6422
|
|
11
11
|
kisa_utils/log.py,sha256=0TYdxcIBts026RCSuVIQBcZ-CW1ES7n3M1nEIjmeLTM,2295
|
|
12
12
|
kisa_utils/queues.py,sha256=9QqPtDujw6tbWk7uUiXrsd0rVBTIkzeQw9b45l5Fo3k,6502
|
|
13
13
|
kisa_utils/remote.py,sha256=0RDrfC4RUW4m6JLziC0_EXJYqzWp38Rw8NDroJ0MuqI,2149
|
|
@@ -23,7 +23,7 @@ kisa_utils/servers/flask.py,sha256=o76cJKlQ3L8EOVdHUF092qwoAZMzgttuLt0mMhtCsGI,4
|
|
|
23
23
|
kisa_utils/structures/__init__.py,sha256=JBU1j3A42jQ62ALKnsS1Hav9YXcYwjDw1wQJtohXPbU,83
|
|
24
24
|
kisa_utils/structures/utils.py,sha256=l56NQiPVcFijpuLqt2n9ZwnVKT4XzK6oknRVallRzwQ,2573
|
|
25
25
|
kisa_utils/structures/validator.py,sha256=Y4UmB4TH7N-GkK22EV1WOsPWjTeqxVWLTentl1keZD4,4053
|
|
26
|
-
kisa_utils-0.37.
|
|
27
|
-
kisa_utils-0.37.
|
|
28
|
-
kisa_utils-0.37.
|
|
29
|
-
kisa_utils-0.37.
|
|
26
|
+
kisa_utils-0.37.10.dist-info/METADATA,sha256=pfh6GQFbwBdENr7T8xWvntPceW2jy1o-G4X1eqsaT-U,478
|
|
27
|
+
kisa_utils-0.37.10.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
28
|
+
kisa_utils-0.37.10.dist-info/top_level.txt,sha256=URxY4sRuqmirOxWtztpVmPoGQdksEMYO6hmYsEDGz2Y,75
|
|
29
|
+
kisa_utils-0.37.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|