jetpytools 1.6.3__tar.gz → 1.6.4__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.

Potentially problematic release.


This version of jetpytools might be problematic. Click here for more details.

Files changed (34) hide show
  1. {jetpytools-1.6.3 → jetpytools-1.6.4}/PKG-INFO +1 -1
  2. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/_metadata.py +1 -1
  3. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/base.py +61 -2
  4. {jetpytools-1.6.3 → jetpytools-1.6.4}/.gitignore +0 -0
  5. {jetpytools-1.6.3 → jetpytools-1.6.4}/LICENSE +0 -0
  6. {jetpytools-1.6.3 → jetpytools-1.6.4}/README.md +0 -0
  7. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/__init__.py +0 -0
  8. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/enums/__init__.py +0 -0
  9. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/enums/base.py +0 -0
  10. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/enums/other.py +0 -0
  11. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/__init__.py +0 -0
  12. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/enum.py +0 -0
  13. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/file.py +0 -0
  14. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/generic.py +0 -0
  15. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/exceptions/module.py +0 -0
  16. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/functions/__init__.py +0 -0
  17. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/functions/funcs.py +0 -0
  18. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/functions/normalize.py +0 -0
  19. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/functions/other.py +0 -0
  20. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/py.typed +0 -0
  21. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/__init__.py +0 -0
  22. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/builtins.py +0 -0
  23. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/check.py +0 -0
  24. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/file.py +0 -0
  25. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/funcs.py +0 -0
  26. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/generic.py +0 -0
  27. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/supports.py +0 -0
  28. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/types/utils.py +0 -0
  29. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/__init__.py +0 -0
  30. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/file.py +0 -0
  31. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/funcs.py +0 -0
  32. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/math.py +0 -0
  33. {jetpytools-1.6.3 → jetpytools-1.6.4}/jetpytools/utils/ranges.py +0 -0
  34. {jetpytools-1.6.3 → jetpytools-1.6.4}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jetpytools
3
- Version: 1.6.3
3
+ Version: 1.6.4
4
4
  Summary: Collection of stuff that's useful in general python programming
5
5
  Project-URL: Source Code, https://github.com/Jaded-Encoding-Thaumaturgy/jetpytools
6
6
  Project-URL: Contact, https://discord.gg/XTpc6Fa9eB
@@ -1,6 +1,6 @@
1
1
  """Collection of stuff that's useful in general python programming"""
2
2
 
3
- __version__ = "1.6.3"
3
+ __version__ = "1.6.4"
4
4
 
5
5
  __author_name__, __author_email__ = "Jaded Encoding Thaumaturgy", "jaded.encoding.thaumaturgy@gmail.com"
6
6
  __maintainer_name__, __maintainer_email__ = __author_name__, __author_email__
@@ -1,8 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import sys
4
+ from contextlib import AbstractContextManager
4
5
  from copy import deepcopy
5
- from typing import TYPE_CHECKING, Any, TypeVar
6
+ from types import TracebackType
7
+ from typing import TYPE_CHECKING, Any, Generic, TypeVar
6
8
 
7
9
  from typing_extensions import Self
8
10
 
@@ -166,12 +168,69 @@ class CustomError(ExceptionError, metaclass=CustomErrorMeta):
166
168
  else:
167
169
  reason = ""
168
170
 
169
- return f"{func_header}{self.message!s}{reason}".format(**self.kwargs).strip()
171
+ out = f"{func_header}{self.message!s}{reason}".format(**self.kwargs).strip()
172
+
173
+ if sys.version_info < (3, 13) and hasattr(self, "__notes__"):
174
+ out += "\n" + "\n".join(self.__notes__)
175
+
176
+ return out
177
+
178
+ if sys.version_info < (3, 13):
179
+ __notes__: list[str]
180
+
181
+ def add_note(self, note: str, /) -> None:
182
+ if not hasattr(self, "__notes__"):
183
+ self.__notes__ = []
184
+
185
+ self.__notes__.append(note)
186
+
187
+ @classmethod
188
+ def catch(cls) -> CatchError[Self]:
189
+ """
190
+ Create a context manager that catches exceptions of this class type.
191
+
192
+ Returns:
193
+ CatchError[Self]: A context manager that will catch and store exceptions of type `cls`
194
+ when used in a `with` block.
195
+ """
196
+ return CatchError(cls)
170
197
 
171
198
 
172
199
  SelfError = TypeVar("SelfError", bound=CustomError)
173
200
 
174
201
 
202
+ class CatchError(AbstractContextManager["CatchError[SelfError]"], Generic[SelfError]):
203
+ """
204
+ Context manager for catching a specific exception type.
205
+ """
206
+
207
+ error: SelfError | None
208
+ """The caught exception instance, if any."""
209
+ tb: TracebackType | None
210
+ """The traceback object associated with the caught exception."""
211
+
212
+ def __init__(self, error: type[SelfError]) -> None:
213
+ self.error = None
214
+ self.tb = None
215
+ self._to_catch_error = error
216
+
217
+ def __enter__(self) -> Self:
218
+ return self
219
+
220
+ def __exit__(
221
+ self,
222
+ exc_type: type[BaseException] | None,
223
+ exc_value: BaseException | None,
224
+ traceback: TracebackType | None,
225
+ ) -> bool | None:
226
+ if isinstance(exc_value, self._to_catch_error):
227
+ self.error = exc_value
228
+ self.tb = traceback
229
+ return True
230
+
231
+ return None
232
+
233
+
175
234
  class CustomValueError(CustomError, ValueError):
176
235
  """Thrown when a specified value is invalid."""
177
236
 
File without changes
File without changes
File without changes
File without changes