UniversalFunctions 1.2.0__tar.gz → 2.0.0__tar.gz

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.
Files changed (27) hide show
  1. {universalfunctions-1.2.0/UniversalFunctions.egg-info → universalfunctions-2.0.0}/PKG-INFO +22 -22
  2. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/README.md +21 -21
  3. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UF/ClassToDict.py +10 -3
  4. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UF/DecoratorArchive.py +6 -6
  5. universalfunctions-2.0.0/UF/GetVariable.py +116 -0
  6. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UF/HelperFunctions.py +7 -6
  7. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UF/StringCheck.py +1 -1
  8. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UF/Trigonometry.py +11 -7
  9. universalfunctions-2.0.0/UF/Validators/Errors.py +103 -0
  10. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UF/Validators/QuantumFuncValidators.py +5 -5
  11. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UF/Validators/QuantumValidators.py +20 -3
  12. universalfunctions-2.0.0/UF/Validators/ValidationClasses.py +406 -0
  13. universalfunctions-2.0.0/UF/Validators/__init__.py +77 -0
  14. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UF/__init__.py +34 -19
  15. {universalfunctions-1.2.0 → universalfunctions-2.0.0/UniversalFunctions.egg-info}/PKG-INFO +22 -22
  16. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UniversalFunctions.egg-info/SOURCES.txt +1 -1
  17. universalfunctions-2.0.0/UniversalFunctions.egg-info/top_level.txt +1 -0
  18. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/pyproject.toml +1 -2
  19. universalfunctions-1.2.0/UF/GetVariable.py +0 -84
  20. universalfunctions-1.2.0/UF/Validators/ValidationClasses.py +0 -230
  21. universalfunctions-1.2.0/UF/Validators/__init__.py +0 -16
  22. universalfunctions-1.2.0/UniversalFunctions.egg-info/top_level.txt +0 -2
  23. universalfunctions-1.2.0/tests/__init__.py +0 -0
  24. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/LICENSE +0 -0
  25. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/UniversalFunctions.egg-info/dependency_links.txt +0 -0
  26. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/setup.cfg +0 -0
  27. {universalfunctions-1.2.0 → universalfunctions-2.0.0}/tests/test_ClassToDict.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UniversalFunctions
3
- Version: 1.2.0
3
+ Version: 2.0.0
4
4
  Summary: A Python utility library providing foundational functions, validators, and infrastructure.
5
5
  Author-email: "Miah M. Sabiq" <miah.sabiq@gibs.at>
6
6
  Requires-Python: >=3.14
@@ -28,10 +28,12 @@ The package requires Python 3.14 or later.
28
28
 
29
29
  UniversalFunctions is imported through the UF Python package:
30
30
 
31
+ ```python
31
32
  from UF.Validators import TypeValidate
32
33
  from numbers import Real
33
34
 
34
35
  TypeValidate(Real)(56)
36
+ ```
35
37
 
36
38
  The distribution name is UniversalFunctions, while the Python import package is UF.
37
39
 
@@ -49,16 +51,25 @@ Provides runtime validation utilities and validation classes for enforcing types
49
51
 
50
52
  #### Notable components include:
51
53
 
52
- * ``TypeValidate``
53
- * ``TupleValidate``
54
- * ``LessThan``
55
- * ``LessOrEqual``
56
- * ``GreaterOrEqual``
57
- * ``Positive``
58
- * ``real_validate``
59
- * ``str_validate``
54
+ * ``TypeValidate`` -> class for validating an object against an expected type
55
+ * ``SequenceValidate`` -> class used to validate a sequence of objects
56
+ * ``LessThan`` -> class to validate a real number, constraint: value < expected
57
+ * ``qtm_validation_decorator`` -> when applied to a function, the decorator takes the provided parameter values and validates them against the expected type
58
+ * ``ErrorDedent``
60
59
  * Callable validation utilities
61
60
 
61
+ This package inside UF contains numerous validators designed to validate all sorts of values and types,
62
+ including some sophisticated ones like SequenceValidate which allows users to enter extra restrictions to the items in a given sequence.
63
+
64
+ There are 2 extra errors which are provided:
65
+ * ``ItemCountError``
66
+ * ``ConstraintError``
67
+
68
+ ItemCountError was created since Python does not have an error for a situation where the values and types
69
+ might be correct, though the number of items is not.
70
+
71
+ ConstraintError provides users to express that the type of a value might be correct, though it fails to pass a specific constraint.
72
+
62
73
  The validation system also contains the Quantum Turtle Mechanics (QTM) validation infrastructure used for more structured runtime validation.
63
74
 
64
75
  ### Decorators
@@ -67,9 +78,8 @@ UniversalFunctions provides reusable decorator infrastructure, including decorat
67
78
 
68
79
  #### Notable components include:
69
80
 
70
- * ``class_decorator``
71
- * ``deco_superposition``
72
- * ``cls_deco_superposition``
81
+ * ``deco_superposition`` -> applies an arbitrary number of decorators to a function
82
+ * ``cls_deco_superposition`` -> applies an arbitrary number of decorators to every function in a class, except for protected ones (names starting with "_")
73
83
  * Quantum Turtle Mechanics validation decorators
74
84
 
75
85
  ### Helper Functions
@@ -106,16 +116,6 @@ Python 3.14 or later
106
116
 
107
117
  UniversalFunctions is designed for modern Python and makes use of contemporary Python typing and language features.
108
118
 
109
- ## Development
110
-
111
- Clone the repository and install it in editable mode:
112
-
113
- git clone https://github.com/Mangosaber2026/UniversalFunctions.git
114
- cd UniversalFunctions
115
- pip install -e .
116
-
117
- Editable installation allows changes to the source code to be reflected immediately without reinstalling the package.
118
-
119
119
  ## License
120
120
 
121
121
  UniversalFunctions is distributed under the terms of the license included in this repository.
@@ -18,10 +18,12 @@ The package requires Python 3.14 or later.
18
18
 
19
19
  UniversalFunctions is imported through the UF Python package:
20
20
 
21
+ ```python
21
22
  from UF.Validators import TypeValidate
22
23
  from numbers import Real
23
24
 
24
25
  TypeValidate(Real)(56)
26
+ ```
25
27
 
26
28
  The distribution name is UniversalFunctions, while the Python import package is UF.
27
29
 
@@ -39,16 +41,25 @@ Provides runtime validation utilities and validation classes for enforcing types
39
41
 
40
42
  #### Notable components include:
41
43
 
42
- * ``TypeValidate``
43
- * ``TupleValidate``
44
- * ``LessThan``
45
- * ``LessOrEqual``
46
- * ``GreaterOrEqual``
47
- * ``Positive``
48
- * ``real_validate``
49
- * ``str_validate``
44
+ * ``TypeValidate`` -> class for validating an object against an expected type
45
+ * ``SequenceValidate`` -> class used to validate a sequence of objects
46
+ * ``LessThan`` -> class to validate a real number, constraint: value < expected
47
+ * ``qtm_validation_decorator`` -> when applied to a function, the decorator takes the provided parameter values and validates them against the expected type
48
+ * ``ErrorDedent``
50
49
  * Callable validation utilities
51
50
 
51
+ This package inside UF contains numerous validators designed to validate all sorts of values and types,
52
+ including some sophisticated ones like SequenceValidate which allows users to enter extra restrictions to the items in a given sequence.
53
+
54
+ There are 2 extra errors which are provided:
55
+ * ``ItemCountError``
56
+ * ``ConstraintError``
57
+
58
+ ItemCountError was created since Python does not have an error for a situation where the values and types
59
+ might be correct, though the number of items is not.
60
+
61
+ ConstraintError provides users to express that the type of a value might be correct, though it fails to pass a specific constraint.
62
+
52
63
  The validation system also contains the Quantum Turtle Mechanics (QTM) validation infrastructure used for more structured runtime validation.
53
64
 
54
65
  ### Decorators
@@ -57,9 +68,8 @@ UniversalFunctions provides reusable decorator infrastructure, including decorat
57
68
 
58
69
  #### Notable components include:
59
70
 
60
- * ``class_decorator``
61
- * ``deco_superposition``
62
- * ``cls_deco_superposition``
71
+ * ``deco_superposition`` -> applies an arbitrary number of decorators to a function
72
+ * ``cls_deco_superposition`` -> applies an arbitrary number of decorators to every function in a class, except for protected ones (names starting with "_")
63
73
  * Quantum Turtle Mechanics validation decorators
64
74
 
65
75
  ### Helper Functions
@@ -96,16 +106,6 @@ Python 3.14 or later
96
106
 
97
107
  UniversalFunctions is designed for modern Python and makes use of contemporary Python typing and language features.
98
108
 
99
- ## Development
100
-
101
- Clone the repository and install it in editable mode:
102
-
103
- git clone https://github.com/Mangosaber2026/UniversalFunctions.git
104
- cd UniversalFunctions
105
- pip install -e .
106
-
107
- Editable installation allows changes to the source code to be reflected immediately without reinstalling the package.
108
-
109
109
  ## License
110
110
 
111
111
  UniversalFunctions is distributed under the terms of the license included in this repository.
@@ -3,17 +3,24 @@ This module contains a function that takes all functions in a class and make a d
3
3
  """
4
4
 
5
5
  from collections.abc import Callable
6
- from .Validators.QuantumFuncValidators import qtm_validation_decorator
6
+ from .Validators import SequenceValidate
7
7
 
8
8
 
9
- @qtm_validation_decorator
10
- def classes_to_dict(*classes: tuple[type, ...]) -> dict[str, Callable]:
9
+ def classes_to_dict(*classes: type) -> dict[str, Callable]:
11
10
  """
12
11
  Extracts callable objects from the given classes and returns them
13
12
  as a dictionary mapping their names to the corresponding objects
13
+
14
+ >>> class RandomClass:
15
+ ... def get_item(self):
16
+ ... pass
17
+ >>> result = classes_to_dict(RandomClass)
18
+ >>> list(result)
19
+ ['get_item']
14
20
  :param classes: Classes from which the callables are extracted
15
21
  :return: Dictionary of callable names and their objects
16
22
  """
23
+ SequenceValidate(type, ...)(classes, name="classes")
17
24
  dictionary = {}
18
25
  for cls in classes:
19
26
  dictionary.update({
@@ -3,16 +3,16 @@ This module contains decorators which take any number of decorators and apply th
3
3
  """
4
4
 
5
5
  from collections.abc import Callable
6
- from .Validators.QuantumFuncValidators import qtm_validation_decorator
6
+ from .Validators import SequenceValidate
7
7
 
8
8
 
9
- @qtm_validation_decorator
10
- def cls_deco_superposition(*decorators: tuple[Callable, ...]) -> Callable:
9
+ def cls_deco_superposition(*decorators: Callable) -> Callable:
11
10
  """
12
11
  DECORATOR!! Creates a class decorator that applies the given decorator to every user defined function
13
- :param decorator: provided decorator function
12
+ :param decorators: provided decorator functions
14
13
  :return: a class decorator that transforms the class (& it's functions) and returns it
15
14
  """
15
+ SequenceValidate(Callable, ...)(decorators, name="decorators")
16
16
  deco_composer = deco_superposition(*decorators)
17
17
 
18
18
  def inner(cls):
@@ -22,13 +22,13 @@ def cls_deco_superposition(*decorators: tuple[Callable, ...]) -> Callable:
22
22
  return cls
23
23
  return inner
24
24
 
25
- @qtm_validation_decorator
26
- def deco_superposition(*decorators: tuple[Callable, ...]) -> Callable:
25
+ def deco_superposition(*decorators: Callable) -> Callable:
27
26
  """
28
27
  DECORATOR! this decorator takes multiple decorators and applies them to the given function the same way python would naturally
29
28
  :param decorators: decorator functions
30
29
  :return: supplied function
31
30
  """
31
+ SequenceValidate(Callable, ...)(decorators, name="decorators")
32
32
  def inner_deco(func):
33
33
  for decorator in reversed(decorators):
34
34
  func = decorator(func)
@@ -0,0 +1,116 @@
1
+ """
2
+ This module contains an extremely important function: get_num, which takes a numerical value from the user.
3
+ """
4
+
5
+ from time import sleep as rest
6
+ from typing import overload, Literal, Final
7
+ from numbers import Real
8
+ from .Validators import (
9
+ LessThan,
10
+ str_validate,
11
+ real_validate,
12
+ TypeValidate,
13
+ GreaterOrEqual,
14
+ LessOrEqual,
15
+ type_error,
16
+ GreaterThan,
17
+ )
18
+
19
+
20
+ type int_type = type[int]
21
+ type float_type = type[float]
22
+
23
+ @overload
24
+ def get_num(TYPE: int_type, entry: str, **options) -> int: ...
25
+
26
+ @overload
27
+ def get_num(TYPE: float_type, entry: str, **options) -> float: ...
28
+
29
+ def get_num(
30
+ TYPE: float_type|int_type,
31
+ entry: str,
32
+ **options
33
+ ) -> Real:
34
+ """
35
+ Gets a real numerical value from the user
36
+
37
+ :param TYPE: float or int; which type of value to check for
38
+ :param entry: str; input string
39
+ :param options: MAX, MIN, store
40
+ :return: float or int
41
+ """
42
+ func_name: Final[Literal["get_num"]] = "get_num"
43
+ type_obj_name: Final[Literal["TYPE"]] = "TYPE"
44
+
45
+ store_var: Final[Literal["store"]] = "store"
46
+ store_value = options[store_var]
47
+
48
+ min_var: Final[Literal["MIN"]] = "MIN"
49
+ min_value = options[min_var]
50
+
51
+ max_var: Final[Literal["MAX"]] = "MAX"
52
+ max_value = options[max_var]
53
+
54
+ if TYPE not in (int, float):
55
+ raise type_error()(f"""
56
+ TypeError
57
+
58
+ Function: {func_name}
59
+ Parameter {type_obj_name} must be type float or int!
60
+ Expected: int or float object
61
+ Received:
62
+ Name: {type_obj_name}
63
+ Value: {TYPE}
64
+ """)
65
+
66
+ str_validate()(entry, name="entry")
67
+
68
+ real_validate()(max_value, name=max_var)
69
+ real_validate()(min_value, name=min_var)
70
+
71
+ if min_var in options and max_var in options:
72
+ LessThan(max_value)(min_value, name=min_var)
73
+
74
+ if store_var in options:
75
+ TypeValidate((Real, type(None)))(store_value, name=store_var)
76
+
77
+ if (
78
+ store_var in options
79
+ and min_var in options
80
+ and max_var in options
81
+ and store_value is not None
82
+ ):
83
+ GreaterThan(min_value)(store_value, name=store_var)
84
+
85
+ while True:
86
+ try:
87
+ if store_var in options:
88
+ reserve: str = input(entry)
89
+ if reserve == "ans":
90
+ if isinstance(store_value, Real):
91
+ value: Real = store_value
92
+ else:
93
+ print("\nThere is no value stored yet!")
94
+ continue
95
+ else:
96
+ value: Real = TYPE(reserve)
97
+ else:
98
+ value: Real = TYPE(input(entry))
99
+ value_name: Literal["value"] = "value"
100
+
101
+ if min_var in options and max_var in options:
102
+ GreaterOrEqual(min_value)(value, name=value_name)
103
+ LessOrEqual(max_value)(value, name=value_name)
104
+
105
+ elif min_var in options:
106
+ GreaterOrEqual(min_value)(value, name=value_name)
107
+
108
+ elif max_var in options:
109
+ LessOrEqual(max_value)(value, name=value_name)
110
+
111
+ elif store_var in options:
112
+ options["store"] = value
113
+ return value
114
+ except ValueError as error:
115
+ print(error)
116
+ rest(1.5)
@@ -15,14 +15,13 @@ from math import sqrt
15
15
  from .GetVariable import get_num
16
16
  from .DecoratorArchive import cls_deco_superposition
17
17
  from .ClassToDict import classes_to_dict
18
- from .Validators.QuantumFuncValidators import qtm_validation_decorator
19
- from .Validators.ValidationClasses import LessThan, Positive
18
+ from .Validators import qtm_validation_decorator, LessThan, Positive
20
19
  from numbers import Real
21
20
 
22
21
 
23
22
  @cls_deco_superposition(staticmethod)
24
23
  class HelperFunctions:
25
-
24
+ """This class provides a collection of reusable helper functions"""
26
25
  def intervals_f() -> Real:
27
26
  """Asks the user for rational intervals"""
28
27
  interval_num: float = get_num(float, "Enter intervals(ℚ>0): ", MIN=0)
@@ -64,8 +63,6 @@ class HelperFunctions:
64
63
  Calculates the diameter of a square with given length
65
64
  :return: diameter, diameter/2
66
65
  """
67
- if length <= 0:
68
- raise ValueError("Length must be greater than 0")
69
66
 
70
67
  diameter: float = length*sqrt(2); d_half: Real = diameter / 2
71
68
  return diameter, d_half
@@ -90,7 +87,11 @@ class HelperFunctions:
90
87
  helper = HelperFunctions
91
88
 
92
89
  @qtm_validation_decorator
93
- def range_f(start: Real, stop: Real, step: Annotated[Real, Positive()]) -> Generator[Real,Any,None]:
90
+ def range_f(
91
+ start: Real,
92
+ stop: Real,
93
+ step: Annotated[Real, Positive()]
94
+ ) -> Generator[Real,Any,None]:
94
95
  """
95
96
  Lets the user choose Real inputs for start, stop and step
96
97
  :param start: start value; Real number
@@ -3,7 +3,7 @@ This module contains an extremely important function: get_str, which takes a str
3
3
  """
4
4
 
5
5
  from time import sleep as rest
6
- from .Validators.ValidationClasses import TypeValidate, str_validate
6
+ from .Validators import TypeValidate, str_validate
7
7
 
8
8
 
9
9
  def get_str(str_input: str, *check_values) -> str:
@@ -1,3 +1,7 @@
1
+ """
2
+ This module contains a collection of trigonometric functions to be used with degrees.
3
+ """
4
+
1
5
  from math import (
2
6
  radians,
3
7
  degrees,
@@ -6,32 +10,32 @@ from math import (
6
10
  asin,
7
11
  )
8
12
  from numbers import Real
9
- from .Validators.QuantumFuncValidators import qtm_validation_decorator
13
+ from .Validators import real_validate
10
14
 
11
15
 
12
- @qtm_validation_decorator
13
16
  def sine(angle: Real) -> Real:
14
17
  """
15
18
  Calculates the sine of a given angle
16
19
  :param angle: value required in degrees
17
20
  :return: sine value
18
21
  """
22
+ real_validate()(angle, name="angle")
19
23
  return sin(radians(angle))
20
24
 
21
- @qtm_validation_decorator
22
25
  def cosine(angle: Real) -> Real:
23
26
  """
24
27
  Calculates the cosine of a given angle
25
28
  :param angle: value required in degrees
26
29
  :return: cosine value
27
30
  """
31
+ real_validate()(angle, name="angle")
28
32
  return cos(radians(angle))
29
33
 
30
- @qtm_validation_decorator
31
- def asine(angle: Real) -> Real:
34
+ def asine(value: Real) -> Real:
32
35
  """
33
36
  Calculates the asine of a given angle
34
- :param angle: real value
37
+ :param value: real value
35
38
  :return: asine value
36
39
  """
37
- return degrees(asin(angle))
40
+ real_validate()(value, name="value")
41
+ return degrees(asin(value))
@@ -0,0 +1,103 @@
1
+ """
2
+ This module provides a collection of error message deliverers and separate errors created by the author which
3
+ are not normally provided with Python.
4
+
5
+ The custom errors in this module can be used just like any other conventional error provided by Python itself.
6
+ """
7
+
8
+ from textwrap import dedent
9
+ from typing import Callable, Final, Literal
10
+
11
+
12
+ class ErrorDedent:
13
+ """
14
+ This class is the error raiser for the other validators found in this package (UF).
15
+
16
+ The use of this class is to make the error message be printed with some formatting instead of the conventional
17
+ way it would be printed otherwise.
18
+
19
+ >>> print(ErrorDedent(TypeError)("This is a TypeError!"))
20
+ This is a TypeError!
21
+ """
22
+ name: Final[Literal["ErrorDedent"]] = "ErrorDedent"
23
+ def __init__(self, error_func) -> None:
24
+ if not isinstance(error_func, type) or not issubclass(error_func, Exception):
25
+ raise TypeError(dedent(f"""
26
+ TypeError:
27
+ Validator: ErrorDedent
28
+ Parameter 'error_func' MUST be an error class!
29
+ expected: Exception subclass
30
+ received: {error_func}
31
+ """).strip())
32
+ self.error_func = error_func
33
+
34
+ def __call__(self, text: str) -> Exception:
35
+ if not isinstance(text, str):
36
+ raise TypeError(dedent(f"""
37
+ TypeError:
38
+ Validator: {self.name}
39
+ Parameter 'text' MUST be a string object!
40
+ expected: str
41
+ received: {text}
42
+ """).strip())
43
+ return self.error_func(dedent(text).strip())
44
+
45
+ def type_error() -> Callable:
46
+ """
47
+ This function returns a callable type error function.
48
+
49
+ >>> print(type_error()("This is a TypeError!"))
50
+ This is a TypeError!
51
+
52
+ :return: ErrorDedent function
53
+ """
54
+ return ErrorDedent(TypeError)
55
+
56
+ def value_error() -> Callable:
57
+ """
58
+ This function returns a callable value error function.
59
+
60
+ >>> print(value_error()("This is a ValueError!"))
61
+ This is a ValueError!
62
+
63
+ :return: ErrorDedent function
64
+ """
65
+ return ErrorDedent(ValueError)
66
+
67
+ def item_count_error() -> Callable:
68
+ """
69
+ This function returns a callable item count error function.
70
+
71
+ >>> print(item_count_error()("This is an Item Count Error!"))
72
+ This is an Item Count Error!
73
+
74
+ :return: ErrorDedent function
75
+ """
76
+ return ErrorDedent(ItemCountError)
77
+
78
+ def constraint_error() -> Callable:
79
+ """
80
+ This function returns a callable constraint error function.
81
+
82
+ >>> print(constraint_error()("This is a Constraint Error!"))
83
+ This is a Constraint Error!
84
+
85
+ :return: ErrorDedent function
86
+ """
87
+ return ErrorDedent(ConstraintError)
88
+
89
+ class ItemCountError(Exception):
90
+ """
91
+ This exception is raised when an item count does not match the expected count.
92
+
93
+ >>> print(ItemCountError("This is an Item Count Error!"))
94
+ This is an Item Count Error!
95
+ """
96
+
97
+ class ConstraintError(Exception):
98
+ """
99
+ This exception is raised when an item does not pass the expected constraint.
100
+
101
+ >>> print(ConstraintError("This is a Constraint Error!"))
102
+ This is a Constraint Error!
103
+ """
@@ -10,13 +10,13 @@ from functools import wraps
10
10
  from .ValidationClasses import TypeValidate
11
11
 
12
12
 
13
- def qtm_func_validator(func: Callable, *args, **kwargs) -> bool:
13
+ def qtm_func_validator(func: Callable, *args, **kwargs) -> Callable:
14
14
  """
15
15
  Takes a function and compares the entered value with the expected type
16
16
  :param func: given function
17
17
  :param args: arguments
18
18
  :param kwargs: keyword arguments
19
- :return: True if the provided argument matches the expected type, raises an error if not
19
+ :return: given function if the provided argument matches the expected type, raises an error if not
20
20
  """
21
21
  TypeValidate(Callable)(func, name=func.__name__)
22
22
  sig = signature(func)
@@ -40,11 +40,11 @@ def qtm_func_validator(func: Callable, *args, **kwargs) -> bool:
40
40
  else:
41
41
  TypeValidate(type_)(value, name=name)
42
42
 
43
- return True
43
+ return func
44
44
 
45
45
  def qtm_validation_decorator(func: Callable) -> Callable:
46
46
  """
47
- DECORATOR!
47
+ QUANTUM DECORATOR!
48
48
 
49
49
  Decorates a function with the quantum function validator and returns the function
50
50
  :param func: provided function
@@ -56,4 +56,4 @@ def qtm_validation_decorator(func: Callable) -> Callable:
56
56
  def wrapper(*args, **kwargs):
57
57
  qtm_func_validator(func, *args, **kwargs)
58
58
  return func(*args, **kwargs)
59
- return wrapper
59
+ return wrapper
@@ -4,6 +4,8 @@ This module contains type validators for list and tuple which belong to the QTM
4
4
 
5
5
  from typing import Any, get_args, get_origin, Annotated
6
6
  from .ValidationClasses import TypeValidate, SequenceValidate
7
+ from .Errors import type_error
8
+ from typing import Final, Literal
7
9
 
8
10
  def qtm_lt_validator(value: list[Any] | tuple[Any, ...], TYPE: Any, name: str) -> tuple | list:
9
11
  """
@@ -17,9 +19,17 @@ def qtm_lt_validator(value: list[Any] | tuple[Any, ...], TYPE: Any, name: str) -
17
19
  :param name: name of value
18
20
  :return: validated list/tuple of elements
19
21
  """
22
+ func_name: Final[Literal["qtm_lt_validator"]] = "qtm_lt_validator"
20
23
  origin = get_origin(TYPE)
21
24
  if origin not in (list, tuple):
22
- raise TypeError(f"{TYPE} must be a list or tuple for a specific type! e.g. list[int]")
25
+ raise type_error()(f"""
26
+ TypeError
27
+
28
+ Validator: {func_name}
29
+ Parameter TYPE must be a list/tuple of elements!
30
+ Expected: type object
31
+ Received: {TYPE}
32
+ """)
23
33
 
24
34
  TypeValidate(origin)(value)
25
35
 
@@ -36,9 +46,16 @@ def qtm_constr_validator(value: Any, annotation, name: str) -> Any:
36
46
  :param name: name of value
37
47
  :return: True, if validation succeeds
38
48
  """
39
-
49
+ func_name: Final[Literal["qtm_constr_validator"]] = "qtm_constr_validator"
40
50
  if get_origin(annotation) is not Annotated:
41
- raise TypeError(f"{annotation} is not an Annotated type!")
51
+ raise type_error()(f"""
52
+ TypeError
53
+
54
+ Validator: {func_name}
55
+ Parameter annotation is not an Annotated type!
56
+ Expected: Annotated object
57
+ Received: {annotation}
58
+ """)
42
59
 
43
60
  type_obj, *constraints = get_args(annotation)
44
61