requiresthat 2025.6.17.0__py3-none-any.whl → 2025.6.17.1__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.
requiresthat/__init__.py CHANGED
@@ -1 +1,8 @@
1
- from ._requires import requires, RequirementNotFulfilledError, APRIORI, POSTMORTEM, BEFOREANDAFTER
1
+ from ._requires import (
2
+ requires,
3
+ RequirementNotFulfilledError,
4
+ NoCallableConstructError,
5
+ APRIORI,
6
+ POSTMORTEM,
7
+ BEFOREANDAFTER,
8
+ )
@@ -1,8 +1,7 @@
1
- """Raise this when a requirement is found wanting"""
2
-
3
1
  import textwrap
4
2
 
5
3
  class RequirementNotFulfilledError(Exception):
4
+ """Raise this when a requirement is found wanting"""
6
5
 
7
6
  def __init__(self, that, when, msg=None):
8
7
  """Show a default or a user-provided message indicating that some condition is unmet"""
@@ -13,3 +12,21 @@ class RequirementNotFulfilledError(Exception):
13
12
 
14
13
  # Call the base class' constructor to init the exception class
15
14
  super().__init__(msg or self.default_msg)
15
+
16
+ class NoCallableConstructError(Exception):
17
+ """Raise this when a construct is not callable"""
18
+
19
+ def __init__(self, construct, msg=None):
20
+ """Show a default or a user-provided message"""
21
+
22
+ self.default_msg = textwrap.dedent(f"""
23
+ {construct!r} does not seem to be callable
24
+
25
+ You have managed to place the decorator before a construct that is not callable
26
+ *without* tripping the Python interpreter. Maybe you are a wizard?
27
+
28
+ But, no, we can't carry on like that. Sorry!
29
+ """).strip()
30
+
31
+ # Call the base class' constructor to init the exception class
32
+ super().__init__(msg or self.default_msg)
requiresthat/_requires.py CHANGED
@@ -4,7 +4,7 @@ from typing import Optional, Callable
4
4
  from functools import wraps
5
5
 
6
6
  from ._when import When, APRIORI, POSTMORTEM, BEFOREANDAFTER
7
- from ._exceptions import RequirementNotFulfilledError
7
+ from ._exceptions import RequirementNotFulfilledError, NoCallableConstructError
8
8
 
9
9
  def requires(that, when: When = APRIORI) -> Optional[Callable]:
10
10
  """Require <that> of the decoratee, and require it <when>"""
@@ -18,6 +18,11 @@ def requires(that, when: When = APRIORI) -> Optional[Callable]:
18
18
 
19
19
  The wrapping stops here...
20
20
  """
21
+ try:
22
+ assert callable(func)
23
+ except AssertionError as exc:
24
+ raise NoCallableConstructError(func) from exc
25
+
21
26
  try:
22
27
  if when == APRIORI:
23
28
  assert eval(that)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: requiresthat
3
- Version: 2025.6.17.0
3
+ Version: 2025.6.17.1
4
4
  Summary: Support for requirements-assisted development
5
5
  Author-email: Ann T Ropea <bedhanger@gmx.de>
6
6
  License-Expression: MIT
@@ -0,0 +1,8 @@
1
+ requiresthat/__init__.py,sha256=VTyJru4K2_e7UEa0od6kXU7M8ovfD176GXEXqtNf-nY,154
2
+ requiresthat/_exceptions.py,sha256=8675wEink7JD3mBsOYCWVL5KYpNQMZ5IQ0C7M2CJ1LU,1186
3
+ requiresthat/_requires.py,sha256=zp99m8m3kRTpS8XKHLBZ0r0eH3skDJEMeKTAZIh6PkU,1748
4
+ requiresthat/_when.py,sha256=VoGuvoG9WDEMIPeKnxAsjMTaCMhgSszf4xxa1vLn5aU,299
5
+ requiresthat-2025.6.17.1.dist-info/METADATA,sha256=HPpmJgWGi2gEtIUQEaCrOezW6MgFVPxrafOSo2Gk3PM,1575
6
+ requiresthat-2025.6.17.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ requiresthat-2025.6.17.1.dist-info/top_level.txt,sha256=mUgMTpAG75GYtt5_rVajUyWp-O_1VrrkqRo_hY9L9So,13
8
+ requiresthat-2025.6.17.1.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- requiresthat/__init__.py,sha256=-pvz61UhmWhwzjbKTHQ83_YqZx1MXQEvqSgb7Q0d9jE,99
2
- requiresthat/_exceptions.py,sha256=bgrTgn3JCJv_KbYIpaghZ8v-SP5fiOpzeFC5zB8uq8M,504
3
- requiresthat/_requires.py,sha256=F28tp_3L_E06ERsSGkPx-YrbBolmGO1NymJZINtocts,1562
4
- requiresthat/_when.py,sha256=VoGuvoG9WDEMIPeKnxAsjMTaCMhgSszf4xxa1vLn5aU,299
5
- requiresthat-2025.6.17.0.dist-info/METADATA,sha256=w3FELaW74-gCOcfxFo9DaiTkLGGJ1LlA17Ka_2itPYM,1575
6
- requiresthat-2025.6.17.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- requiresthat-2025.6.17.0.dist-info/top_level.txt,sha256=mUgMTpAG75GYtt5_rVajUyWp-O_1VrrkqRo_hY9L9So,13
8
- requiresthat-2025.6.17.0.dist-info/RECORD,,