simplibs-rules 0.1.0__tar.gz → 0.2.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 (156) hide show
  1. {simplibs_rules-0.1.0/src/simplibs_rules.egg-info → simplibs_rules-0.2.0}/PKG-INFO +6 -25
  2. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/README.md +5 -24
  3. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/pyproject.toml +1 -1
  4. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/__init__.py +0 -11
  5. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/testing/__init__.py +0 -3
  6. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/testing/assert_rule_contract.py +7 -48
  7. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/testing/asserts/__init__.py +1 -4
  8. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0/src/simplibs_rules.egg-info}/PKG-INFO +6 -25
  9. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs_rules.egg-info/SOURCES.txt +0 -3
  10. simplibs_rules-0.1.0/src/simplibs/rules/testing/asserts/assert_rule_raise_invalid.py +0 -91
  11. simplibs_rules-0.1.0/src/simplibs/rules/tools/__init__.py +0 -16
  12. simplibs_rules-0.1.0/src/simplibs/rules/tools/raise_invalid.py +0 -84
  13. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/LICENSE +0 -0
  14. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/setup.cfg +0 -0
  15. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/base_class/Rule.py +0 -0
  16. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/base_class/_NotARule.py +0 -0
  17. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/base_class/__init__.py +0 -0
  18. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/AllOf.py +0 -0
  19. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/AnyOf.py +0 -0
  20. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/Compose.py +0 -0
  21. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/ForEach.py +0 -0
  22. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/NoneOf.py +0 -0
  23. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/Not.py +0 -0
  24. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/__init__.py +0 -0
  25. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_helpers/__init__.py +0 -0
  26. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_helpers/as_predicate.py +0 -0
  27. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_helpers/build_child_exception.py +0 -0
  28. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_helpers/describe_rule.py +0 -0
  29. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_helpers/validations/__init__.py +0 -0
  30. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_helpers/validations/raise_invalid_predicate.py +0 -0
  31. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_init_validators/__init__.py +0 -0
  32. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_init_validators/raise_container_param_not_type_error.py +0 -0
  33. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_init_validators/raise_requires_at_least_one_rule_error.py +0 -0
  34. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_init_validators/raise_rule_param_not_callable.py +0 -0
  35. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/containers/_init_validators/validate_compose_param_is_callable.py +0 -0
  36. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/__init__.py +0 -0
  37. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_helpers/__init__.py +0 -0
  38. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_helpers/accepts_one_positional_argument.py +0 -0
  39. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_helpers/format_container.py +0 -0
  40. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/__init__.py +0 -0
  41. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/rule_errors/__init__.py +0 -0
  42. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/rule_errors/raise_has_length_param_conflict_error.py +0 -0
  43. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/rule_errors/raise_regex_param_invalid_pattern_error.py +0 -0
  44. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/rule_errors/raise_user_rule_param_wrong_arity.py +0 -0
  45. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_errors/__init__.py +0 -0
  46. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_errors/raise_param_min_max_bounds_inverted_error.py +0 -0
  47. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_errors/raise_param_min_max_incomparable_error.py +0 -0
  48. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_errors/raise_param_missing_error.py +0 -0
  49. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_errors/raise_param_not_callable_error.py +0 -0
  50. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_errors/raise_param_not_container_error.py +0 -0
  51. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_errors/raise_param_not_non_negative_integer_error.py +0 -0
  52. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_errors/raise_param_not_string_error.py +0 -0
  53. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_errors/raise_param_not_type_error.py +0 -0
  54. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_validators/__init__.py +0 -0
  55. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_validators/validate_param_is_integer.py +0 -0
  56. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_validators/validate_param_is_not_zero.py +0 -0
  57. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_validators/validate_param_is_primitive_number.py +0 -0
  58. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/_init_validators/shared_validators/validate_param_remainder_in_range.py +0 -0
  59. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/arithmetic/CloseTo.py +0 -0
  60. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/arithmetic/DivisibleBy.py +0 -0
  61. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/arithmetic/HasRemainder.py +0 -0
  62. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/arithmetic/__init__.py +0 -0
  63. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/checkers/IsEmpty.py +0 -0
  64. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/checkers/IsFalse.py +0 -0
  65. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/checkers/IsNone.py +0 -0
  66. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/checkers/IsTrue.py +0 -0
  67. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/checkers/NotEmpty.py +0 -0
  68. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/checkers/__init__.py +0 -0
  69. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/collections/AllUnique.py +0 -0
  70. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/collections/HasItem.py +0 -0
  71. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/collections/HasKey.py +0 -0
  72. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/collections/HasKeys.py +0 -0
  73. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/collections/IsContainer.py +0 -0
  74. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/collections/IsSubsetOf.py +0 -0
  75. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/collections/IsSupersetOf.py +0 -0
  76. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/collections/__init__.py +0 -0
  77. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/comparisons/Equals.py +0 -0
  78. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/comparisons/GreaterOrEqual.py +0 -0
  79. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/comparisons/GreaterThan.py +0 -0
  80. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/comparisons/InRange.py +0 -0
  81. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/comparisons/LessOrEqual.py +0 -0
  82. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/comparisons/LessThan.py +0 -0
  83. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/comparisons/NotEquals.py +0 -0
  84. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/comparisons/__init__.py +0 -0
  85. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/HasAttribute.py +0 -0
  86. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/HasLength.py +0 -0
  87. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/IsCallable.py +0 -0
  88. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/IsDataclass.py +0 -0
  89. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/IsHashable.py +0 -0
  90. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/IsInstance.py +0 -0
  91. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/IsIterable.py +0 -0
  92. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/IsSubclass.py +0 -0
  93. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/IsType.py +0 -0
  94. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/introspection/__init__.py +0 -0
  95. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/logic/Is.py +0 -0
  96. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/logic/IsIn.py +0 -0
  97. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/logic/IsNot.py +0 -0
  98. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/logic/NotIn.py +0 -0
  99. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/logic/UserRule.py +0 -0
  100. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/logic/__init__.py +0 -0
  101. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsBool.py +0 -0
  102. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsDecimal.py +0 -0
  103. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsEven.py +0 -0
  104. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsFinite.py +0 -0
  105. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsFloat.py +0 -0
  106. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsInfinity.py +0 -0
  107. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsInteger.py +0 -0
  108. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsNan.py +0 -0
  109. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsNumber.py +0 -0
  110. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsOdd.py +0 -0
  111. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsPi.py +0 -0
  112. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsPrimitiveNumber.py +0 -0
  113. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/IsZero.py +0 -0
  114. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/numeric/__init__.py +0 -0
  115. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/Contains.py +0 -0
  116. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/EndsWith.py +0 -0
  117. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsAlnum.py +0 -0
  118. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsAlpha.py +0 -0
  119. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsAscii.py +0 -0
  120. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsBlank.py +0 -0
  121. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsDigitString.py +0 -0
  122. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsLowercase.py +0 -0
  123. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsString.py +0 -0
  124. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsSubstringOf.py +0 -0
  125. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsTitlecase.py +0 -0
  126. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/IsUppercase.py +0 -0
  127. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/NotBlank.py +0 -0
  128. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/Regex.py +0 -0
  129. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/StartsWith.py +0 -0
  130. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/strings/__init__.py +0 -0
  131. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/IsAny.py +0 -0
  132. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/IsTyping.py +0 -0
  133. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/__init__.py +0 -0
  134. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/ORIGIN_TABLE.py +0 -0
  135. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/__init__.py +0 -0
  136. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/build_annotated_rule.py +0 -0
  137. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/build_any_of_rule.py +0 -0
  138. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/build_callable_rule.py +0 -0
  139. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/build_elements_rule.py +0 -0
  140. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/build_key_value_rule.py +0 -0
  141. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/build_literal_rule.py +0 -0
  142. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/build_tuple_rule.py +0 -0
  143. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_builders/build_type_rule.py +0 -0
  144. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_validations/__init__.py +0 -0
  145. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/_validations/raise_unsupported_annotation_error.py +0 -0
  146. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/build_typing_rule.py +0 -0
  147. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/tools/__init__.py +0 -0
  148. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/tools/get_supported_origins.py +0 -0
  149. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/predicates/typing/tools/is_supported_annotation.py +0 -0
  150. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/testing/asserts/assert_rule_build_exception.py +0 -0
  151. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/testing/asserts/assert_rule_is_valid.py +0 -0
  152. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/testing/asserts/assert_rule_param_error.py +0 -0
  153. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs/rules/testing/asserts/assert_rule_validate.py +0 -0
  154. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs_rules.egg-info/dependency_links.txt +0 -0
  155. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs_rules.egg-info/requires.txt +0 -0
  156. {simplibs_rules-0.1.0 → simplibs_rules-0.2.0}/src/simplibs_rules.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simplibs-rules
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Composable, explicit validation rules — pure predicates, zero transformation.
5
5
  Author-email: "Dalibor Sova (Sudip2708)" <daliborsova@seznam.cz>
6
6
  License-Expression: MIT
@@ -134,22 +134,6 @@ typing_rule.is_valid({"apples": 5, "oranges": 10}) # -> True
134
134
  typing_rule.is_valid({"apples": "5"}) # -> False
135
135
  ```
136
136
 
137
- ### Level 4: Unconditional direct triggers
138
-
139
- When control flow guards in your application have already detected a failure condition
140
- inline, use `raise_invalid()` to bypass rule evaluation entirely and construct the
141
- diagnostic exception immediately:
142
-
143
- ```python
144
- from simplibs.rules import raise_invalid, is_integer
145
-
146
- value = -5
147
-
148
- if value < 0:
149
- # Bypasses evaluation and directly raises the structured exception card
150
- raise_invalid(value, is_integer, value_name="age", context="Must be non-negative")
151
- ```
152
-
153
137
  ---
154
138
 
155
139
  ## 🛠️ Architecture & Package Structure
@@ -170,8 +154,6 @@ src/simplibs/rules/
170
154
  │ ├── numeric/ ◄── IsBool, IsInteger, IsFloat, IsDecimal, IsNumber, IsPrimitiveNumber, IsZero, IsNan, IsInfinity, IsPi
171
155
  │ ├── strings/ ◄── IsString, Contains, IsSubstringOf, StartsWith, EndsWith, Regex, IsBlank, NotBlank
172
156
  │ └── typing/ ◄── Annotation-driven evaluation (IsAny, IsTyping, build_typing_rule)
173
- ├── tools/ ◄── Operational helper utilities
174
- │ └── raise_invalid.py ◄── Unconditional exception trigger (bypasses logic evaluation)
175
157
  └── testing/ ◄── Testing contracts for Rule implementations
176
158
  └── assert_rule_contract.py
177
159
  ```
@@ -299,8 +281,8 @@ mechanism that also powers `simplibs-validate`'s `validate_call`/`validate_datac
299
281
  `simplibs-rules` includes its own contract testing tools to ensure custom or existing `Rule`
300
282
  implementations strictly follow all rules and return modes:
301
283
 
302
- * **`assert_rule_contract`**: Verifies `is_valid`, direct calling, `validate()` matrix,
303
- return modes, exception generation, and `raise_invalid()` consistency for any `Rule` instance.
284
+ assert_rule_contract: Verifies is_valid, direct calling, validate() matrix, return modes,
285
+ and exception generation consistency for any Rule instance.
304
286
 
305
287
  ➡️ [README_TESTING_ASSERTS_RULE_CONTRACT](https://github.com/simplibs/simplibs-rules/blob/main/docs/testing/README_TESTING_ASSERTS_RULE_CONTRACT.md)
306
288
 
@@ -308,7 +290,7 @@ implementations strictly follow all rules and return modes:
308
290
 
309
291
  ## ⚠️ Exceptions
310
292
 
311
- Diagnostic exceptions built by `build_exception()`/`raise_invalid()` are structured
293
+ Diagnostic exceptions built by `build_exception()` are structured
312
294
  [`simplibs.exception.SimpleException`](https://pypi.org/project/simplibs-exception/) cards
313
295
  rather than bare tracebacks. `simplibs-validate` builds its own `ValidateError` hierarchy
314
296
  on top of the same mechanism for the higher-level entry points (`validate()`,
@@ -319,9 +301,8 @@ on top of the same mechanism for the higher-level entry points (`validate()`,
319
301
  ## 🔗 Related libraries
320
302
 
321
303
  * **[`simplibs-validate`](https://pypi.org/project/simplibs-validate/)** — the `validate()`
322
- entry point, ready-made `validate_*` wrappers, and self-validating decorators
323
- (`validate_call`, `validate_dataclass`) built on top of `Rule`. `raise_invalid()`
324
- lives here, in `simplibs-rules`, not there.
304
+ entry point, ready-made validate_* wrappers, operational tools (raise_invalid, validated_type),
305
+ and self-validating decorators (validate_call, validate_dataclass) built on top of Rule.
325
306
  * **`simplibs-types`** *(in progress)* — reusable, named validated types (`Annotated[type,
326
307
  Rule]` combinations) built on `Rule`, for sharing a single constraint definition across
327
308
  many annotations.
@@ -106,22 +106,6 @@ typing_rule.is_valid({"apples": 5, "oranges": 10}) # -> True
106
106
  typing_rule.is_valid({"apples": "5"}) # -> False
107
107
  ```
108
108
 
109
- ### Level 4: Unconditional direct triggers
110
-
111
- When control flow guards in your application have already detected a failure condition
112
- inline, use `raise_invalid()` to bypass rule evaluation entirely and construct the
113
- diagnostic exception immediately:
114
-
115
- ```python
116
- from simplibs.rules import raise_invalid, is_integer
117
-
118
- value = -5
119
-
120
- if value < 0:
121
- # Bypasses evaluation and directly raises the structured exception card
122
- raise_invalid(value, is_integer, value_name="age", context="Must be non-negative")
123
- ```
124
-
125
109
  ---
126
110
 
127
111
  ## 🛠️ Architecture & Package Structure
@@ -142,8 +126,6 @@ src/simplibs/rules/
142
126
  │ ├── numeric/ ◄── IsBool, IsInteger, IsFloat, IsDecimal, IsNumber, IsPrimitiveNumber, IsZero, IsNan, IsInfinity, IsPi
143
127
  │ ├── strings/ ◄── IsString, Contains, IsSubstringOf, StartsWith, EndsWith, Regex, IsBlank, NotBlank
144
128
  │ └── typing/ ◄── Annotation-driven evaluation (IsAny, IsTyping, build_typing_rule)
145
- ├── tools/ ◄── Operational helper utilities
146
- │ └── raise_invalid.py ◄── Unconditional exception trigger (bypasses logic evaluation)
147
129
  └── testing/ ◄── Testing contracts for Rule implementations
148
130
  └── assert_rule_contract.py
149
131
  ```
@@ -271,8 +253,8 @@ mechanism that also powers `simplibs-validate`'s `validate_call`/`validate_datac
271
253
  `simplibs-rules` includes its own contract testing tools to ensure custom or existing `Rule`
272
254
  implementations strictly follow all rules and return modes:
273
255
 
274
- * **`assert_rule_contract`**: Verifies `is_valid`, direct calling, `validate()` matrix,
275
- return modes, exception generation, and `raise_invalid()` consistency for any `Rule` instance.
256
+ assert_rule_contract: Verifies is_valid, direct calling, validate() matrix, return modes,
257
+ and exception generation consistency for any Rule instance.
276
258
 
277
259
  ➡️ [README_TESTING_ASSERTS_RULE_CONTRACT](https://github.com/simplibs/simplibs-rules/blob/main/docs/testing/README_TESTING_ASSERTS_RULE_CONTRACT.md)
278
260
 
@@ -280,7 +262,7 @@ implementations strictly follow all rules and return modes:
280
262
 
281
263
  ## ⚠️ Exceptions
282
264
 
283
- Diagnostic exceptions built by `build_exception()`/`raise_invalid()` are structured
265
+ Diagnostic exceptions built by `build_exception()` are structured
284
266
  [`simplibs.exception.SimpleException`](https://pypi.org/project/simplibs-exception/) cards
285
267
  rather than bare tracebacks. `simplibs-validate` builds its own `ValidateError` hierarchy
286
268
  on top of the same mechanism for the higher-level entry points (`validate()`,
@@ -291,9 +273,8 @@ on top of the same mechanism for the higher-level entry points (`validate()`,
291
273
  ## 🔗 Related libraries
292
274
 
293
275
  * **[`simplibs-validate`](https://pypi.org/project/simplibs-validate/)** — the `validate()`
294
- entry point, ready-made `validate_*` wrappers, and self-validating decorators
295
- (`validate_call`, `validate_dataclass`) built on top of `Rule`. `raise_invalid()`
296
- lives here, in `simplibs-rules`, not there.
276
+ entry point, ready-made validate_* wrappers, operational tools (raise_invalid, validated_type),
277
+ and self-validating decorators (validate_call, validate_dataclass) built on top of Rule.
297
278
  * **`simplibs-types`** *(in progress)* — reusable, named validated types (`Annotated[type,
298
279
  Rule]` combinations) built on `Rule`, for sharing a single constraint definition across
299
280
  many annotations.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "simplibs-rules"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "Composable, explicit validation rules — pure predicates, zero transformation."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -118,9 +118,6 @@ from .predicates.typing import (
118
118
  is_supported_annotation
119
119
  )
120
120
 
121
- # Tools
122
- from .tools import raise_invalid
123
-
124
121
 
125
122
  # ============================================================================
126
123
  # Rule shortcuts
@@ -570,9 +567,6 @@ __all__ = [
570
567
  "get_supported_origins",
571
568
  "is_supported_annotation",
572
569
 
573
- # tools
574
- "raise_invalid",
575
-
576
570
  # shortcuts
577
571
  "all_of",
578
572
  "any_of",
@@ -935,9 +929,4 @@ are compound names rather than the keywords themselves.
935
929
  | `is_any` | — | Alias for `always_true` (accepts any value). |
936
930
  | `is_typing` | `annotation` | Value must satisfy the given typing annotation. |
937
931
 
938
- ## 6. Tools (`tools/`)
939
- Provides execution utilities for direct exception management and control flow optimization:
940
- - `raise_invalid`: Directly builds and triggers a structured `ValidationError` for
941
- a failed `Rule` or plain callable predicate. Used in "happy path" control flow guards
942
- where a condition failure has already been determined inline, avoiding redundant rule re-evaluation.
943
932
  """
@@ -5,7 +5,6 @@ from .asserts import (
5
5
  assert_rule_build_exception,
6
6
  assert_rule_is_valid,
7
7
  assert_rule_param_error,
8
- assert_rule_raise_invalid,
9
8
  assert_rule_validate,
10
9
  )
11
10
 
@@ -14,7 +13,6 @@ __all__ = [
14
13
  "assert_rule_build_exception",
15
14
  "assert_rule_is_valid",
16
15
  "assert_rule_param_error",
17
- "assert_rule_raise_invalid",
18
16
  "assert_rule_validate",
19
17
  ]
20
18
 
@@ -35,6 +33,5 @@ implementations across the library ecosystem.
35
33
  | `assert_rule_build_exception` | Function | Verifies that `build_exception()` yields expected `ValidationError` cards. |
36
34
  | `assert_rule_is_valid` | Function | Asserts boolean `is_valid()` results across valid and invalid inputs. |
37
35
  | `assert_rule_param_error` | Function | Verifies that rule instantiation fails properly on invalid init arguments. |
38
- | `assert_rule_raise_invalid` | Function | Verifies that `raise_invalid()` raises the expected `ValidationError`. |
39
36
  | `assert_rule_validate` | Function | Verifies `validate()` execution, pass-through return values, and errors. |
40
37
  """
@@ -6,7 +6,6 @@ from .asserts.assert_rule_is_valid import assert_rule_is_valid
6
6
  from .asserts.assert_rule_validate import assert_rule_validate
7
7
  from .asserts.assert_rule_build_exception import assert_rule_build_exception
8
8
  from .asserts.assert_rule_param_error import assert_rule_param_error
9
- from .asserts.assert_rule_raise_invalid import assert_rule_raise_invalid
10
9
 
11
10
 
12
11
  def assert_rule_contract(
@@ -22,48 +21,22 @@ def assert_rule_contract(
22
21
  sample_label: str = "target_var",
23
22
  sample_context: str = "test_execution_context",
24
23
  check_value: bool = True,
25
- check_raise_invalid: bool = False,
26
24
  verbose: bool = True,
27
25
  intro: str = "",
28
26
  deep_check: bool = True,
29
27
  ) -> None:
30
- """Master orchestrator for testing rule compliance against the simplibs-validate contract.
28
+ """Master orchestrator for testing rule compliance against the simplibs-rules contract.
31
29
 
32
30
  Runs the full battery of deterministic checks a well-formed `Rule` subclass must
33
31
  satisfy: the `is_valid()`/`__call__` boolean contract, the `validate()` mode matrix,
34
32
  the `build_exception()` diagnostic card contract, and — optionally — the constructor's
35
- `ParamError` guard and the standalone `raise_invalid()` dispatcher.
33
+ `ParamError` guard.
36
34
 
37
35
  Everything checked here is deterministic given valid_values/invalid_values, so a single
38
36
  call replaces most of what a hand-written test module for a Rule subclass would need.
39
37
  Anything rule-specific beyond this (e.g. asserting exact `problem`/`how_to_fix` wording
40
38
  for one particular invalid value) is expected to be written as an additional, focused
41
39
  test alongside this call — not folded into the generic contract.
42
-
43
- Args:
44
- subtests: The native pytest subtests fixture manager instance.
45
- rule: The Rule instance under test.
46
- valid_values: Values that must satisfy the rule.
47
- invalid_values: Values that must fail the rule and produce a diagnostic exception.
48
- expected_error_name: If provided, asserted against every raised exception's error_name.
49
- expected_exception_type: If provided, asserted against every raised exception's
50
- wrapped `exception` attribute.
51
- rule_factory: The rule class (or a factory callable) used to test constructor
52
- guards. Required, together with invalid_init_params, to run the constructor
53
- ParamError check.
54
- invalid_init_params: A list of (args, kwargs) pairs expected to raise ParamError
55
- when passed to rule_factory. Required, together with rule_factory, to run the
56
- constructor ParamError check.
57
- sample_label: The value_name used when probing build_exception()/raise_invalid().
58
- sample_context: The context used when probing build_exception().
59
- check_value: If True, asserts that exc.value strictly matches the raw invalid value.
60
- Set to False for rules that modify/transform values before failure (e.g. Compose).
61
- check_raise_invalid: If True, additionally verifies the standalone raise_invalid()
62
- function against this rule.
63
- verbose: If True, registers individual checks as isolated pytest subtests.
64
- intro: Optional prefix string added to the generated subtest identity name.
65
- deep_check: If True, triggers exhaustive diagnostic field inspection in the
66
- build_exception and constructor checks.
67
40
  """
68
41
  assert isinstance(rule, Rule), (
69
42
  f"assert_rule_contract expects a Rule instance, got {type(rule).__name__}."
@@ -107,17 +80,7 @@ def assert_rule_contract(
107
80
  intro=prefix,
108
81
  )
109
82
 
110
- # 4. Optional: standalone raise_invalid() dispatcher
111
- if check_raise_invalid:
112
- assert_rule_raise_invalid(
113
- subtests,
114
- rule,
115
- invalid_values,
116
- verbose=verbose,
117
- intro=prefix,
118
- )
119
-
120
- # 5. Optional constructor ParamError check
83
+ # 4. Optional constructor ParamError check
121
84
  if deep_check and invalid_init_params and rule_factory:
122
85
  assert_rule_param_error(
123
86
  subtests,
@@ -132,7 +95,7 @@ _DESIGN_NOTES = """
132
95
  # assert_rule_contract (Master Rule Compliance Orchestrator)
133
96
 
134
97
  ## Purpose
135
- The single entry point for testing any `simplibs-validate` `Rule` subclass.
98
+ The single entry point for testing any `simplibs-rules` `Rule` subclass.
136
99
  Mirrors the Facade pattern used by `assert_exception_function` /
137
100
  `assert_exception_class` in `simplibs-exception`: one call, fed with data
138
101
  (valid/invalid values, and optionally constructor misuse cases), exercises
@@ -146,15 +109,11 @@ every deterministic corner of the `Rule` contract.
146
109
  2. **`validate` check** — the `validate()` mode matrix (raise / return_value / return_bool).
147
110
  3. **`build_exception` check** — `build_exception()` produces a well-formed, raisable card.
148
111
  Supports `check_value=False` for transformation rules (e.g. `Compose`).
149
- 4. **`raise_invalid` check** (opt-in via `check_raise_invalid`) — the standalone
150
- `raise_invalid()` dispatcher agrees with `build_exception()`.
151
- 5. **constructor `ParamError` check** (opt-in via `rule_factory` +
112
+ 4. **constructor `ParamError` check** (opt-in via `rule_factory` +
152
113
  `invalid_init_params`) — the constructor rejects bad configuration with `ParamError`.
153
114
 
154
- Steps 4 and 5 are opt-in because not every rule has constructor parameters
155
- worth misuse-testing (e.g. `IsNone`, `IsTrue`), and `raise_invalid` is a
156
- thin, generic dispatcher shared by every rule — most callers won't need to
157
- re-verify it per rule.
115
+ Step 4 is opt-in because not every rule has constructor parameters
116
+ worth misuse-testing (e.g. `IsNone`, `IsTrue`).
158
117
 
159
118
  ---
160
119
 
@@ -3,7 +3,6 @@
3
3
  from .assert_rule_build_exception import assert_rule_build_exception
4
4
  from .assert_rule_is_valid import assert_rule_is_valid
5
5
  from .assert_rule_param_error import assert_rule_param_error
6
- from .assert_rule_raise_invalid import assert_rule_raise_invalid
7
6
  from .assert_rule_validate import assert_rule_validate
8
7
 
9
8
 
@@ -12,8 +11,7 @@ _DESIGN_NOTES = """
12
11
 
13
12
  ## Purpose
14
13
  Internal assertions module providing granular test helpers for individual methods
15
- of validation rules (`is_valid`, `validate`, `build_exception`, `raise_invalid`,
16
- and constructor `ParamError` validation).
14
+ of validation rules (`is_valid`, `validate`, `build_exception`, and constructor `ParamError` validation).
17
15
 
18
16
  ## Exported Components Registry
19
17
 
@@ -22,6 +20,5 @@ and constructor `ParamError` validation).
22
20
  | `assert_rule_build_exception` | Function | Verifies that `build_exception()` yields expected `ValidationError` cards. |
23
21
  | `assert_rule_is_valid` | Function | Asserts boolean `is_valid()` results across valid and invalid inputs. |
24
22
  | `assert_rule_param_error` | Function | Verifies that rule instantiation fails properly on invalid init arguments. |
25
- | `assert_rule_raise_invalid` | Function | Verifies that `raise_invalid()` raises the expected `ValidationError`. |
26
23
  | `assert_rule_validate` | Function | Verifies `validate()` execution, pass-through return values, and errors. |
27
24
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simplibs-rules
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Composable, explicit validation rules — pure predicates, zero transformation.
5
5
  Author-email: "Dalibor Sova (Sudip2708)" <daliborsova@seznam.cz>
6
6
  License-Expression: MIT
@@ -134,22 +134,6 @@ typing_rule.is_valid({"apples": 5, "oranges": 10}) # -> True
134
134
  typing_rule.is_valid({"apples": "5"}) # -> False
135
135
  ```
136
136
 
137
- ### Level 4: Unconditional direct triggers
138
-
139
- When control flow guards in your application have already detected a failure condition
140
- inline, use `raise_invalid()` to bypass rule evaluation entirely and construct the
141
- diagnostic exception immediately:
142
-
143
- ```python
144
- from simplibs.rules import raise_invalid, is_integer
145
-
146
- value = -5
147
-
148
- if value < 0:
149
- # Bypasses evaluation and directly raises the structured exception card
150
- raise_invalid(value, is_integer, value_name="age", context="Must be non-negative")
151
- ```
152
-
153
137
  ---
154
138
 
155
139
  ## 🛠️ Architecture & Package Structure
@@ -170,8 +154,6 @@ src/simplibs/rules/
170
154
  │ ├── numeric/ ◄── IsBool, IsInteger, IsFloat, IsDecimal, IsNumber, IsPrimitiveNumber, IsZero, IsNan, IsInfinity, IsPi
171
155
  │ ├── strings/ ◄── IsString, Contains, IsSubstringOf, StartsWith, EndsWith, Regex, IsBlank, NotBlank
172
156
  │ └── typing/ ◄── Annotation-driven evaluation (IsAny, IsTyping, build_typing_rule)
173
- ├── tools/ ◄── Operational helper utilities
174
- │ └── raise_invalid.py ◄── Unconditional exception trigger (bypasses logic evaluation)
175
157
  └── testing/ ◄── Testing contracts for Rule implementations
176
158
  └── assert_rule_contract.py
177
159
  ```
@@ -299,8 +281,8 @@ mechanism that also powers `simplibs-validate`'s `validate_call`/`validate_datac
299
281
  `simplibs-rules` includes its own contract testing tools to ensure custom or existing `Rule`
300
282
  implementations strictly follow all rules and return modes:
301
283
 
302
- * **`assert_rule_contract`**: Verifies `is_valid`, direct calling, `validate()` matrix,
303
- return modes, exception generation, and `raise_invalid()` consistency for any `Rule` instance.
284
+ assert_rule_contract: Verifies is_valid, direct calling, validate() matrix, return modes,
285
+ and exception generation consistency for any Rule instance.
304
286
 
305
287
  ➡️ [README_TESTING_ASSERTS_RULE_CONTRACT](https://github.com/simplibs/simplibs-rules/blob/main/docs/testing/README_TESTING_ASSERTS_RULE_CONTRACT.md)
306
288
 
@@ -308,7 +290,7 @@ implementations strictly follow all rules and return modes:
308
290
 
309
291
  ## ⚠️ Exceptions
310
292
 
311
- Diagnostic exceptions built by `build_exception()`/`raise_invalid()` are structured
293
+ Diagnostic exceptions built by `build_exception()` are structured
312
294
  [`simplibs.exception.SimpleException`](https://pypi.org/project/simplibs-exception/) cards
313
295
  rather than bare tracebacks. `simplibs-validate` builds its own `ValidateError` hierarchy
314
296
  on top of the same mechanism for the higher-level entry points (`validate()`,
@@ -319,9 +301,8 @@ on top of the same mechanism for the higher-level entry points (`validate()`,
319
301
  ## 🔗 Related libraries
320
302
 
321
303
  * **[`simplibs-validate`](https://pypi.org/project/simplibs-validate/)** — the `validate()`
322
- entry point, ready-made `validate_*` wrappers, and self-validating decorators
323
- (`validate_call`, `validate_dataclass`) built on top of `Rule`. `raise_invalid()`
324
- lives here, in `simplibs-rules`, not there.
304
+ entry point, ready-made validate_* wrappers, operational tools (raise_invalid, validated_type),
305
+ and self-validating decorators (validate_call, validate_dataclass) built on top of Rule.
325
306
  * **`simplibs-types`** *(in progress)* — reusable, named validated types (`Annotated[type,
326
307
  Rule]` combinations) built on `Rule`, for sharing a single constraint definition across
327
308
  many annotations.
@@ -143,10 +143,7 @@ src/simplibs/rules/testing/asserts/__init__.py
143
143
  src/simplibs/rules/testing/asserts/assert_rule_build_exception.py
144
144
  src/simplibs/rules/testing/asserts/assert_rule_is_valid.py
145
145
  src/simplibs/rules/testing/asserts/assert_rule_param_error.py
146
- src/simplibs/rules/testing/asserts/assert_rule_raise_invalid.py
147
146
  src/simplibs/rules/testing/asserts/assert_rule_validate.py
148
- src/simplibs/rules/tools/__init__.py
149
- src/simplibs/rules/tools/raise_invalid.py
150
147
  src/simplibs_rules.egg-info/PKG-INFO
151
148
  src/simplibs_rules.egg-info/SOURCES.txt
152
149
  src/simplibs_rules.egg-info/dependency_links.txt
@@ -1,91 +0,0 @@
1
- from typing import Any
2
- from simplibs.exception.testing import maybe_subtest
3
- # Outers
4
- from ...tools import raise_invalid
5
- from ...base_class import Rule
6
-
7
-
8
- def assert_rule_raise_invalid(
9
- subtests: Any,
10
- rule: Rule,
11
- invalid_values: list[Any],
12
- *,
13
- verbose: bool = True,
14
- intro: str = "",
15
- ) -> None:
16
- """Verify that the standalone raise_invalid() function raises for a Rule the same way build_exception() would.
17
-
18
- Args:
19
- subtests: The native pytest subtests fixture manager instance.
20
- rule: The Rule instance under test.
21
- invalid_values: Values expected to trigger raise_invalid() unconditionally.
22
- verbose: Enables isolated pytest subtest tracking for each checked value.
23
- intro: Optional prefix string added to generated subtest identity names.
24
- """
25
-
26
- for index, val in enumerate(invalid_values):
27
- with maybe_subtest(
28
- subtests,
29
- name=f"{intro}test_raise_invalid_#index_{index}",
30
- verbose=verbose,
31
- ):
32
- expected_exc = rule.build_exception(val)
33
-
34
- raised: BaseException | None = None
35
- try:
36
- raise_invalid(val, rule)
37
- except BaseException as exc: # noqa: BLE001 — capturing to compare type below
38
- raised = exc
39
-
40
- assert raised is not None, (
41
- f"raise_invalid(value={val!r}, rule) did not raise, "
42
- f"expected {type(expected_exc).__name__}."
43
- )
44
- assert type(raised) is type(expected_exc), (
45
- f"raise_invalid(value={val!r}, rule) raised {type(raised).__name__}, "
46
- f"expected {type(expected_exc).__name__} (matching rule.build_exception())."
47
- )
48
-
49
-
50
- _DESIGN_NOTES = """
51
- # assert_rule_raise_invalid (Unconditional Raise Contract Blade)
52
-
53
- ## Purpose
54
- Verifies the standalone `raise_invalid()` function — the "condition
55
- already checked, just raise" counterpart to `validate()` — for a given
56
- `Rule` instance. Nothing else in this testing toolkit previously exercised
57
- `raise_invalid()`.
58
-
59
- ---
60
-
61
- ## 1. Execution Rationale
62
-
63
- * **Type-Equivalence Contract:**
64
- `raise_invalid()` and `Rule.build_exception()` are guaranteed by design
65
- to construct the exception the same way when the rule branch is taken
66
- (`raise_invalid` literally calls `rule.build_exception(...)` internally
67
- for `Rule` instances — see its own design notes). This blade asserts
68
- that guarantee holds by comparing the *type* of what `raise_invalid`
69
- actually raises against a freshly built reference exception from
70
- `rule.build_exception(val)`.
71
- * **Why Type, Not Full Field Equality:**
72
- Two independently constructed exception instances for the same `val`
73
- are expected to carry equal diagnostic content, but stack-trace-derived
74
- fields (`caller_info`) will legitimately differ between the two call
75
- sites. Comparing `type(...)` keeps this check meaningful without
76
- becoming a brittle, unintended assertion on stack location.
77
- * **No Value/Value-Name Echo Assertions:**
78
- Unlike `assert_rule_build_exception`, this helper calls `raise_invalid`
79
- with no `value_name`/`context`, since its only job is to confirm the
80
- unconditional raise path is wired correctly for this rule — full field
81
- content is already exhaustively covered by `assert_rule_build_exception`.
82
-
83
- ---
84
-
85
- ## 2. Placement in the Contract
86
-
87
- Optional in `assert_rule_contract` (only run when the caller wants it),
88
- since `raise_invalid` is a thin, generic dispatcher shared by every rule
89
- in the ecosystem — most contract runs won't need to re-verify it per
90
- rule, but it remains available for thoroughness.
91
- """
@@ -1,16 +0,0 @@
1
- from .raise_invalid import raise_invalid
2
-
3
-
4
- _DESIGN_NOTES = """
5
- # Tools Sub-Package
6
-
7
- ## Purpose
8
- Provides standalone operational helper utilities that operate alongside the Rule engine,
9
- enabling direct exception triggers and control flow shortcuts without re-evaluating conditions.
10
-
11
- ## Registry
12
-
13
- | Component | Type | Description |
14
- | :-------------- | :------- | :------------------------------------------------------------------------------ |
15
- | `raise_invalid` | Function | Unconditionally constructs and raises a ValidationError for a given rule/callable. |
16
- """
@@ -1,84 +0,0 @@
1
- from typing import Any, Callable, NoReturn
2
- from simplibs.exception import build_validation_error
3
- # Inners
4
- from ..base_class import Rule
5
-
6
-
7
- def raise_invalid(
8
- value: Any,
9
- rule: Rule | Callable[[Any], bool],
10
- *,
11
- value_name: str | None = None,
12
- context: str | None = None,
13
- ) -> NoReturn:
14
- """Unconditionally raise a validation exception associated with the given rule.
15
-
16
- This function does not evaluate the truthiness of the rule (`is_valid` / callable is not called).
17
- It serves as a direct shortcut for scenarios where conditional code has already verified a failure,
18
- and the sole objective is to construct and raise the corresponding `ValidationError`.
19
-
20
- Args:
21
- value: The value that failed validation.
22
- rule: A rule instance (`Rule`) or callable object used to construct the exception.
23
- value_name: The name of the validated parameter/variable for diagnostic reporting.
24
- context: Additional context describing the validation failure.
25
-
26
- Raises:
27
- ValidationError: Always raises the exception constructed by the rule or fallback factory.
28
- """
29
-
30
- # 1. Rule instance handling
31
- if isinstance(rule, Rule):
32
- raise rule.build_exception(
33
- value,
34
- value_name=value_name,
35
- context=context,
36
- )
37
-
38
- # 2. Callable handling (plain function / lambda)
39
- raise build_validation_error(
40
- rule,
41
- value,
42
- value_name=value_name,
43
- context=context,
44
- )
45
-
46
-
47
- _DESIGN_NOTES = """
48
- # raise_invalid — Unconditional Validation Exception Trigger
49
-
50
- ## Purpose
51
- The `raise_invalid()` function provides a direct shortcut for raising
52
- structured validation exceptions without re-evaluating conditions. It is
53
- designed for the "happy path" pattern where control flow guards have already
54
- detected a failure condition inline.
55
-
56
- ---
57
-
58
- ## 1. Execution Pipeline
59
-
60
- 1. **Bypassing Evaluation Logic:**
61
- * Unlike `validate()`, this function **never calls** `rule(value)` or
62
- `rule.is_valid(value)`.
63
- * It assumes the calling context has already determined validation
64
- failure.
65
-
66
- 2. **Exception Construction & Dispatch:**
67
- * **`isinstance(rule, Rule)`:** Delegates exception construction to
68
- `rule.build_exception()`.
69
- * **Callable / Lambda:** Delegates construction to the universal fallback
70
- factory `build_validation_error()`.
71
- * The resulting exception is raised immediately (`NoReturn`).
72
-
73
- ---
74
-
75
- ## 2. Design Choices & Rationale
76
-
77
- ### Semantic Distinction from `validate()`
78
- * Using `validate()` makes sense when the developer wants the library to
79
- evaluate the condition and trigger errors automatically.
80
- * Using `raise_invalid()` is ideal under an `if not condition:` block,
81
- explicitly communicating intent: *"The condition has already been checked;
82
- now assemble and raise the diagnostic error card."*
83
- * Avoids double-executing potentially expensive rule logic.
84
- """
File without changes
File without changes