catchlib 1.0.4__tar.gz → 1.0.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: catchlib
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: This project allows to catch exceptions easily.
5
5
  Author-email: Johannes <johannes.programming@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -26,7 +26,7 @@ keywords = []
26
26
  name = "catchlib"
27
27
  readme = "README.rst"
28
28
  requires-python = ">=3.11"
29
- version = "1.0.4"
29
+ version = "1.0.6"
30
30
 
31
31
  [project.license]
32
32
  file = "LICENSE.txt"
@@ -1,10 +1,10 @@
1
1
  from contextlib import contextmanager
2
2
  from typing import *
3
3
 
4
- from overloadable import Overloadable
5
-
6
4
  __all__ = ["Catcher"]
7
5
 
6
+ DEFAULT = object()
7
+
8
8
 
9
9
  class Catcher:
10
10
  "This class catches exceptions."
@@ -32,25 +32,23 @@ class Catcher:
32
32
  "This property stores the caught exception."
33
33
  return self._caught
34
34
 
35
- @Overloadable
36
- def release(self: Self, *args: Any, **kwargs: Any) -> bool:
37
- "This method raises the caught exception."
38
- return bool(len(args) + len(kwargs))
35
+ @overload
36
+ def release(self: Self) -> None: ...
39
37
 
40
- @release.overload(False)
41
- def release(self: Self) -> None:
42
- "This method raises the caught exception."
43
- exc: BaseException
44
- exc = self.caught
45
- self._caught = None
46
- if exc is not None:
47
- raise exc
38
+ @overload
39
+ def release(self: Self, cause: Optional[BaseException]) -> None: ...
48
40
 
49
- @release.overload(True)
50
- def release(self: Self, cause: Optional[BaseException]) -> None:
41
+ def release(
42
+ self: Self,
43
+ cause: BaseException | None | object = DEFAULT,
44
+ ) -> None:
51
45
  "This method raises the caught exception."
52
46
  exc: BaseException
53
47
  exc = self.caught
54
48
  self._caught = None
55
- if exc is not None:
49
+ if exc is None:
50
+ return
51
+ if cause is DEFAULT:
52
+ raise exc
53
+ else:
56
54
  raise exc from cause
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: catchlib
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: This project allows to catch exceptions easily.
5
5
  Author-email: Johannes <johannes.programming@gmail.com>
6
6
  License: The MIT License (MIT)
File without changes
File without changes
File without changes
File without changes