errortools 2.3.0__tar.gz → 2.5.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.
- {errortools-2.3.0 → errortools-2.5.0}/PKG-INFO +38 -8
- errortools-2.3.0/errortools.egg-info/PKG-INFO → errortools-2.5.0/README.md +329 -335
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/classes/abc.py +6 -1
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/const.py +6 -4
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/decorator/deprecated.py +1 -1
- errortools-2.5.0/_errortools/errno.py +86 -0
- errortools-2.5.0/_errortools/future.py +165 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/logging/level.py +4 -4
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/logging/sink.py +2 -2
- errortools-2.5.0/_errortools/partial.py +199 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/version.py +2 -2
- errortools-2.5.0/errortools/future.py +5 -0
- errortools-2.5.0/errortools/logging.py +46 -0
- errortools-2.5.0/errortools/partial.py +5 -0
- errortools-2.3.0/README.md → errortools-2.5.0/errortools.egg-info/PKG-INFO +365 -300
- {errortools-2.3.0 → errortools-2.5.0}/errortools.egg-info/SOURCES.txt +4 -0
- errortools-2.5.0/setup.py +79 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/__init__.py +1 -1
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_decorator.py +3 -3
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_errno.py +5 -2
- errortools-2.5.0/tests/test_future.py +302 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_logging.py +7 -5
- errortools-2.3.0/_errortools/errno.py +0 -78
- errortools-2.3.0/_errortools/future.py +0 -23
- errortools-2.3.0/_errortools/partial.py +0 -110
- errortools-2.3.0/setup.py +0 -35
- {errortools-2.3.0 → errortools-2.5.0}/AUTHORS.txt +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/LICENSE.txt +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/__init__.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/_cli.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/classes/__init__.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/classes/errorcodes.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/classes/group.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/classes/warn.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/cli.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/decorator/__init__.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/decorator/cache.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/descriptor/__init__.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/descriptor/errormsg.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/descriptor/nonblankmsg.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/ignore.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/logging/__init__.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/logging/base.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/logging/logger.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/logging/record.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/metadata.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/methods/__init__.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/methods/errorattr.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/methods/errordelattr.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/methods/errorhasattr.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/methods/errorsetattr.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/py.typed +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/raises.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/typing.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/wrappers/__init__.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/wrappers/cache.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/_errortools/wrappers/ignore.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/errortools/__init__.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/errortools/__main__.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/errortools.egg-info/dependency_links.txt +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/errortools.egg-info/entry_points.txt +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/errortools.egg-info/requires.txt +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/errortools.egg-info/top_level.txt +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/setup.cfg +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/conftest.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/run_tests.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_abc.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_const.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_descriptor.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_errorcodes.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_groups.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_ignore.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_mixins.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_partials.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_raises.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_typing.py +0 -0
- {errortools-2.3.0 → errortools-2.5.0}/tests/test_warnings.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: errortools
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: errortools - a toolset for working with Python exceptions and warnings and logging.
|
|
5
5
|
Home-page: https://github.com/more-abc/errortools
|
|
6
6
|
Author: Evan Yang
|
|
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
16
17
|
Classifier: Operating System :: OS Independent
|
|
17
18
|
Classifier: Typing :: Typed
|
|
18
19
|
Requires-Python: >=3.10
|
|
@@ -36,9 +37,18 @@ Dynamic: summary
|
|
|
36
37
|
# errortools
|
|
37
38
|
A lightweight Python exception handling utility library.
|
|
38
39
|
|
|
40
|
+
[](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings)
|
|
41
|
+
[](https://pypi.org/project/errortools/)
|
|
42
|
+
[](https://pypi.org/project/errortools/)
|
|
43
|
+

|
|
44
|
+

|
|
45
|
+

|
|
46
|
+

|
|
47
|
+
|
|
39
48
|
## Features
|
|
40
49
|
- **Raise Exceptions**: `raises()`, `raises_all()`, `reraise()` — batch raising and exception conversion
|
|
41
50
|
- **Catch & Suppress**: `ignore()`, `ignore_subclass()`, `ignore_warns()`, `fast_ignore()`, `super_fast_ignore()`, `timeout()`, `retry()` — graceful suppression of exceptions and warnings, with automatic retry
|
|
51
|
+
- **Future Utilities**: `super_fast_catch()`, `super_fast_reraise()`, `ExceptionCollector` — lightweight exception handling for high-performance scenarios
|
|
42
52
|
- **Exception Caching**: `error_cache` — cache exceptions raised by functions (similar to `lru_cache`)
|
|
43
53
|
- **Custom Exceptions**: `PureBaseException`, `ContextException`, `BaseErrorCodes`, `BaseWarning` — structured exception classes with error codes, trace IDs, and context
|
|
44
54
|
- **Attribute Error Mixin**: Customize error behavior for attribute access, assignment, and deletion
|
|
@@ -62,7 +72,7 @@ from errortools import (
|
|
|
62
72
|
error_cache,
|
|
63
73
|
PureBaseException, ContextException, BaseErrorCodes, BaseWarning,
|
|
64
74
|
)
|
|
65
|
-
from errortools.future import super_fast_ignore
|
|
75
|
+
from errortools.future import super_fast_ignore, super_fast_catch, super_fast_reraise, ExceptionCollector
|
|
66
76
|
|
|
67
77
|
# ── 1. ignore ── context manager with full metadata ──────────────────────────
|
|
68
78
|
with ignore(KeyError) as err:
|
|
@@ -154,7 +164,27 @@ raises_all(
|
|
|
154
164
|
exc = assert_raises(int, [ValueError], "not-a-number")
|
|
155
165
|
print(exc) # invalid literal for int() with base 10: 'not-a-number'
|
|
156
166
|
|
|
157
|
-
# ── 10.
|
|
167
|
+
# ── 10. super_fast_catch ── lightweight exception capture ──────────────────────
|
|
168
|
+
with super_fast_catch(ValueError) as ctx:
|
|
169
|
+
raise ValueError("oops")
|
|
170
|
+
|
|
171
|
+
assert ctx.exception is not None
|
|
172
|
+
print(ctx.exception) # ValueError('oops')
|
|
173
|
+
|
|
174
|
+
# ── 11. super_fast_reraise ── lightweight exception type conversion ────────────
|
|
175
|
+
with super_fast_reraise(KeyError, ValueError):
|
|
176
|
+
raise KeyError("missing") # → ValueError: 'missing'
|
|
177
|
+
|
|
178
|
+
# ── 12. ExceptionCollector ── batch collect exceptions ───────────────────────────
|
|
179
|
+
collector = ExceptionCollector()
|
|
180
|
+
collector.catch(int, "bad1")
|
|
181
|
+
collector.catch(int, "bad2")
|
|
182
|
+
|
|
183
|
+
if collector.has_errors:
|
|
184
|
+
print(f"Collected {collector.count} errors")
|
|
185
|
+
collector.raise_all("batch operation failed") # → ExceptionGroup (2 sub-exceptions)
|
|
186
|
+
|
|
187
|
+
# ── 13. error_cache ── cache exceptions by call arguments ─────────────────────
|
|
158
188
|
@error_cache(maxsize=64)
|
|
159
189
|
def load(user_id: int) -> dict:
|
|
160
190
|
if user_id < 0:
|
|
@@ -167,7 +197,7 @@ with ignore(ValueError):
|
|
|
167
197
|
print(load.cache_info()) # CacheInfo(hits=0, misses=1, maxsize=64, currsize=1)
|
|
168
198
|
load.clear_cache()
|
|
169
199
|
|
|
170
|
-
# ──
|
|
200
|
+
# ── 14. Custom exceptions — three layers ──────────────────────────────────────
|
|
171
201
|
|
|
172
202
|
# Layer 1: PureBaseException — code + detail only
|
|
173
203
|
class AppError(PureBaseException):
|
|
@@ -203,7 +233,7 @@ raise BaseErrorCodes.runtime_failure("crash") # RuntimeFailure [
|
|
|
203
233
|
raise BaseErrorCodes.timeout_failure() # TimeoutFailure [4002]
|
|
204
234
|
raise BaseErrorCodes.configuration_error("missing key") # ConfigurationError [5001]
|
|
205
235
|
|
|
206
|
-
# ──
|
|
236
|
+
# ── 15. BaseWarning ── structured warnings with factory methods ───────────────
|
|
207
237
|
class ExperimentalWarning(BaseWarning):
|
|
208
238
|
default_detail = "This feature is experimental."
|
|
209
239
|
|
|
@@ -234,9 +264,9 @@ logger.success("All systems operational")
|
|
|
234
264
|
Output (colourised in a terminal):
|
|
235
265
|
|
|
236
266
|
```
|
|
237
|
-
2026-
|
|
238
|
-
2026-
|
|
239
|
-
2026-
|
|
267
|
+
2026-04-30 08:34:21.850 | ℹ INFO | <string>:<module>:3 - Server started on port 8080
|
|
268
|
+
2026-04-30 08:34:21.851 | ⚠ WARNING | <string>:<module>:4 - Disk at 92.5%
|
|
269
|
+
2026-04-30 08:34:21.851 | ✔ SUCCESS | <string>:<module>:5 - All systems operational
|
|
240
270
|
```
|
|
241
271
|
|
|
242
272
|
### Log levels
|