retrpy 0.1.0__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.
retrpy/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Retry and fallback as plans of attempts, composed with ``*`` and ``+``."""
2
+
3
+ from retrpy._plan import Plan, attempt
4
+
5
+ __all__ = ["Plan", "attempt"]
retrpy/_plan.py ADDED
@@ -0,0 +1,149 @@
1
+ """Plans of attempts: retry is repetition, fallback is concatenation."""
2
+
3
+ import math
4
+ import time
5
+ from collections.abc import Callable, Iterator
6
+ from dataclasses import dataclass, replace
7
+ from functools import partial
8
+ from typing import Self, cast
9
+
10
+
11
+ @dataclass(frozen=True, slots=True)
12
+ class Segment[T]:
13
+ """One zero-argument callable repeated ``count`` times; backoff restarts per segment."""
14
+
15
+ fn: Callable[[], T]
16
+ count: int
17
+
18
+
19
+ @dataclass(frozen=True, slots=True)
20
+ class Plan[T]:
21
+ """An immutable, ordered sequence of attempts; the first one that succeeds wins.
22
+
23
+ The plan keeps its segments rather than a flat list of calls, because the wait between
24
+ attempts grows within a segment and restarts when the plan falls back to the next one.
25
+ """
26
+
27
+ segments: tuple[Segment[T], ...]
28
+
29
+ def __len__(self) -> int:
30
+ return sum(segment.count for segment in self.segments)
31
+
32
+ def __iter__(self) -> Iterator[Callable[[], T]]:
33
+ for segment in self.segments:
34
+ yield from [segment.fn] * segment.count
35
+
36
+ def __call__(
37
+ self,
38
+ *,
39
+ delay: float = 0.0,
40
+ backoff: float = 1.0,
41
+ catch: tuple[type[Exception], ...] = (Exception,),
42
+ max_delay: float | None = None,
43
+ jitter: Callable[[float], float] | None = None,
44
+ on_failure: Callable[[Exception, int], None] | None = None,
45
+ sleep: Callable[[float], object] = time.sleep,
46
+ ) -> T:
47
+ """Run the attempts in order and return the first success.
48
+
49
+ Exceptions outside ``catch`` propagate at once, unwrapped; ``catch`` only takes
50
+ ``Exception`` subclasses, so ``KeyboardInterrupt`` and cancellation always get through.
51
+ Within a segment the wait
52
+ before the next try is ``delay * backoff**k``, with ``k`` restarting at each segment,
53
+ so a backup source never inherits the primary's grown delay. Switching segments does
54
+ not wait. ``jitter`` maps each wait to a new one (it owns its RNG, so tests can pass a
55
+ deterministic one), and ``max_delay`` then caps it; a wait of zero or less skips
56
+ ``sleep``. ``on_failure(error, number)`` sees every caught failure, numbered from 1
57
+ across the whole plan, including the last. When every attempt fails, an
58
+ ``ExceptionGroup`` holds all the failures in order, so callers can use ``except*``.
59
+ """
60
+
61
+ if not self.segments:
62
+ msg = "Cannot run an empty plan"
63
+ raise ValueError(msg)
64
+
65
+ # The annotation can't stop untyped callers; catching BaseException would swallow Ctrl-C.
66
+ if not all(issubclass(kind, Exception) for kind in catch):
67
+ msg = f"catch only takes Exception subclasses, never BaseException; got {catch!r}"
68
+ raise TypeError(msg)
69
+
70
+ errors: list[Exception] = []
71
+
72
+ for segment in self.segments:
73
+ for k in range(segment.count):
74
+ try:
75
+ return segment.fn()
76
+
77
+ except catch as error:
78
+ errors.append(error)
79
+
80
+ if on_failure is not None:
81
+ on_failure(error, len(errors))
82
+
83
+ if (
84
+ k < segment.count - 1
85
+ and (wait := _wait(delay, backoff, k, jitter, max_delay)) > 0
86
+ ):
87
+ sleep(wait)
88
+
89
+ msg = f"all {len(errors)} attempts failed"
90
+
91
+ raise ExceptionGroup(msg, errors)
92
+
93
+ def __mul__(self, n: int) -> Self:
94
+ if not isinstance(n, int):
95
+ return NotImplemented
96
+
97
+ if n < 1:
98
+ msg = f"Plan can only be repeated at least 1 time, got {n}"
99
+ raise ValueError(msg)
100
+
101
+ # One segment grows its count so its backoff keeps growing; anything else repeats.
102
+ if len(self.segments) == 1:
103
+ (segment,) = self.segments
104
+
105
+ return replace(self, segments=(Segment(segment.fn, segment.count * n),))
106
+
107
+ return replace(self, segments=self.segments * n)
108
+
109
+ __rmul__ = __mul__
110
+
111
+ def __add__[U](self, other: "Plan[U]") -> "Plan[T | U]":
112
+ if not isinstance(other, Plan):
113
+ return NotImplemented
114
+
115
+ segments: tuple[Segment[T | U], ...] = (*self.segments, *other.segments)
116
+
117
+ # Widen self's type so replace() keeps the subclass and accepts the wider segments.
118
+ return replace(cast("Plan[T | U]", self), segments=segments)
119
+
120
+
121
+ def attempt[T, **P](fn: Callable[P, T], /, *args: P.args, **kwargs: P.kwargs) -> Plan[T]:
122
+ """Bind ``fn`` to its arguments as a one-attempt plan, ready for ``*`` and ``+``."""
123
+ return Plan((Segment(partial(fn, *args, **kwargs), 1),))
124
+
125
+
126
+ # --- private helpers
127
+
128
+
129
+ def _wait(
130
+ delay: float,
131
+ backoff: float,
132
+ k: int,
133
+ jitter: Callable[[float], float] | None,
134
+ max_delay: float | None,
135
+ ) -> float:
136
+ try:
137
+ wait = delay * backoff**k
138
+
139
+ except OverflowError:
140
+ # Long retry budgets outgrow floats; max_delay still caps the infinite wait.
141
+ wait = math.inf
142
+
143
+ if jitter is not None:
144
+ wait = jitter(wait)
145
+
146
+ if max_delay is not None:
147
+ wait = min(wait, max_delay)
148
+
149
+ return wait
retrpy/py.typed ADDED
File without changes
@@ -0,0 +1,420 @@
1
+ Metadata-Version: 2.5
2
+ Name: retrpy
3
+ Version: 0.1.0
4
+ Summary: Retry and fallback as plans of attempts, composed with * and +.
5
+ Project-URL: Homepage, https://github.com/aaltatan/retrpy
6
+ Project-URL: Repository, https://github.com/aaltatan/retrpy
7
+ Project-URL: Issues, https://github.com/aaltatan/retrpy/issues
8
+ Author-email: aaltatan <a.altatan@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: backoff,fallback,functional,jitter,resilience,retry
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.12
22
+ Description-Content-Type: text/markdown
23
+
24
+ # retrpy
25
+
26
+ Retry and fallback as **plans of attempts**, composed with ordinary Python operators.
27
+ Zero dependencies, fully typed.
28
+
29
+ ```python
30
+ from retrpy import attempt
31
+
32
+ plan = (
33
+ attempt(fetch_rate, client, primary_url) * 3 # try the primary 3 times
34
+ + attempt(fetch_rate, client, backup_url) * 2 # then the backup twice
35
+ + attempt(lambda: None) # then give up with None
36
+ )
37
+ rate = plan(delay=0.05, backoff=2.0, catch=(NetworkError, RetryableHTTPError))
38
+ ```
39
+
40
+ A plan is a value: build it once, run it as often as you like, pass it around, `len()` it.
41
+ The first attempt that succeeds wins.
42
+
43
+ ## The problem it solves
44
+
45
+ A nightly job turns the day's orders into invoices, and each order total has to be converted
46
+ from USD to EUR. The exchange-rate provider is usually fine, but now and then it times out,
47
+ answers `503`, or rate-limits you with `429`. When that happens at 2 a.m., the job dies and
48
+ nobody gets invoiced.
49
+
50
+ You want: retry the main provider a few times with a growing wait, then switch to a second
51
+ provider, and as a last resort use yesterday's rate from your own database. Log every failure.
52
+ Never retry a real bug. And keep it testable without waiting for real.
53
+
54
+ Written by hand, that usually ends up like this:
55
+
56
+ ```python
57
+ def get_rate() -> float:
58
+ last_error = None
59
+ wait = 0.5
60
+ for url in (PRIMARY, SECONDARY):
61
+ for _ in range(3):
62
+ try:
63
+ return fetch_rate(url, "USD", "EUR")
64
+ except (TimeoutError, ConnectionError, RetryableHTTPError) as error:
65
+ log.warning("rate fetch failed: %r", error)
66
+ last_error = error
67
+ time.sleep(wait) # sleeps after the last try too
68
+ wait *= 2 # the secondary inherits the primary's grown wait
69
+ try:
70
+ return load_cached_rate("USD", "EUR")
71
+ except LookupError:
72
+ raise last_error # earlier failures are lost
73
+ ```
74
+
75
+ It works, but it's hard to read and has quiet bugs. The secondary provider starts at a 4-second
76
+ wait instead of 0.5. It sleeps for nothing before switching source. Only the last error
77
+ survives. And `time.sleep` is hard-wired, so the tests really sleep.
78
+
79
+ With retrpy, the plan says exactly what you meant, and the bugs go away:
80
+
81
+ ```python
82
+ import logging
83
+
84
+ from retrpy import attempt
85
+
86
+ log = logging.getLogger("invoicing")
87
+
88
+ rate_plan = (
89
+ attempt(fetch_rate, PRIMARY, "USD", "EUR") * 3 # main provider, 3 tries
90
+ + attempt(fetch_rate, SECONDARY, "USD", "EUR") * 3 # backup provider, fresh backoff
91
+ + attempt(load_cached_rate, "USD", "EUR") # yesterday's rate from the database
92
+ )
93
+
94
+
95
+ def get_rate(sleep=time.sleep) -> float:
96
+ return rate_plan(
97
+ delay=0.5,
98
+ backoff=2.0,
99
+ max_delay=10.0,
100
+ catch=(TimeoutError, ConnectionError, RetryableHTTPError, LookupError),
101
+ on_failure=lambda error, n: log.warning("rate attempt %d failed: %r", n, error),
102
+ sleep=sleep,
103
+ )
104
+ ```
105
+
106
+ What you get:
107
+
108
+ - **Each provider gets its own backoff**: 0.5 s and 1 s between the primary's tries, then the
109
+ same again for the secondary. There's no wait when switching source.
110
+ - **Bugs fail fast.** A `KeyError` from a changed JSON shape isn't in `catch`, so it surfaces on
111
+ the first try, unwrapped, with its real traceback.
112
+ - **Nothing is lost.** If even the cache is empty, the job raises one `ExceptionGroup` with all
113
+ seven failures, so the morning report shows exactly what went wrong and in what order.
114
+ - **Tests are instant.** Pass `sleep=waits.append` and assert on the waits.
115
+ - **The policy is a value.** `rate_plan` can be imported, reused by another job, or extended
116
+ with `+`.
117
+
118
+ ## Install
119
+
120
+ ```bash
121
+ uv add retrpy
122
+ ```
123
+
124
+ ```bash
125
+ pip install retrpy
126
+ ```
127
+
128
+ ## Building plans
129
+
130
+ | Expression | Meaning |
131
+ | --- | --- |
132
+ | `attempt(fn, *args, **kwargs)` | one attempt of `fn(*args, **kwargs)` |
133
+ | `p * n` or `n * p` | retry: repeat `n` times (`n >= 1`) |
134
+ | `p + q` | fallback: run `q`'s attempts after `p`'s |
135
+ | `+ attempt(lambda: default)` | a default value is just one more attempt |
136
+
137
+ The operators behave like they do on tuples: `(a * 2) * 3` is six attempts of `a`, and
138
+ `(a * 2 + b) * 3` repeats the whole sequence three times.
139
+
140
+ ## Running
141
+
142
+ ```python
143
+ plan(
144
+ delay=0.0, # first wait between retries, in seconds
145
+ backoff=1.0, # each next wait is multiplied by this
146
+ catch=(Exception,), # only these are retried; anything else propagates at once
147
+ max_delay=None, # cap on a single wait
148
+ jitter=None, # e.g. lambda d: d * random.uniform(0.5, 1.0)
149
+ on_failure=None, # e.g. lambda error, number: log.warning("attempt %d: %r", number, error)
150
+ sleep=time.sleep, # inject a fake in tests
151
+ )
152
+ ```
153
+
154
+ - Backoff **restarts for each segment**. In `primary * 3 + backup * 2`, the backup starts again
155
+ from `delay` instead of inheriting the primary's grown wait. There's no wait when switching
156
+ to the next source.
157
+ - The wait is `delay * backoff**k`, then `jitter`, then capped by `max_delay`. A wait of zero
158
+ or less doesn't sleep.
159
+ - Long retry budgets are safe with a cap. If `delay * backoff**k` grows too big for a float
160
+ (around 1,000 doublings), the wait becomes infinite instead of raising `OverflowError`, and
161
+ `max_delay` caps it as usual. Without `max_delay`, set a cap or keep the count reasonable:
162
+ an infinite wait makes `time.sleep` itself raise.
163
+ - Errors outside `catch` propagate immediately and unwrapped. `KeyboardInterrupt` and other
164
+ `BaseException`s are never caught.
165
+ - To retry on a bad *result*, make the attempt raise: for example, turn HTTP 429/5xx into a
166
+ `RetryableHTTPError`.
167
+
168
+ ## When everything fails
169
+
170
+ All failures are raised together, in order, as an `ExceptionGroup`:
171
+
172
+ ```python
173
+ try:
174
+ rate = plan(catch=(NetworkError,))
175
+ except* NetworkError as group:
176
+ for error in group.exceptions:
177
+ log.error("failed: %r", error)
178
+ ```
179
+
180
+ ## Examples
181
+
182
+ ### HTTP with a mirror and a default
183
+
184
+ Retry on a bad *response* by making the attempt raise. Here, 429 and 5xx become
185
+ `RetryableHTTPError`; a 404 stays an `HTTPError` and fails fast, because it's not in `catch`.
186
+
187
+ ```python
188
+ import json
189
+ import urllib.error
190
+ import urllib.request
191
+
192
+ from retrpy import attempt
193
+
194
+
195
+ class RetryableHTTPError(Exception):
196
+ pass
197
+
198
+
199
+ def fetch_rate(url: str, currency: str) -> float:
200
+ try:
201
+ with urllib.request.urlopen(f"{url}/rates/{currency}", timeout=5) as response:
202
+ return float(json.load(response)["rate"])
203
+ except urllib.error.HTTPError as error:
204
+ if error.code == 429 or error.code >= 500:
205
+ raise RetryableHTTPError(error.code) from error
206
+ raise
207
+
208
+
209
+ plan = (
210
+ attempt(fetch_rate, "https://api.example.com", "EUR") * 3
211
+ + attempt(fetch_rate, "https://mirror.example.com", "EUR") * 2
212
+ + attempt(lambda: None)
213
+ ) # Plan[float | None]
214
+
215
+ rate = plan(
216
+ delay=0.2,
217
+ backoff=2.0,
218
+ catch=(urllib.error.URLError, TimeoutError, RetryableHTTPError),
219
+ )
220
+ ```
221
+
222
+ The waits are `0.2, 0.4` on the primary, then no wait, then `0.2` on the mirror: the
223
+ mirror's backoff starts fresh.
224
+
225
+ ### Exponential backoff with full jitter and a cap
226
+
227
+ Jitter spreads out clients that failed at the same moment, so they don't all retry in sync.
228
+ `jitter` gets the computed wait and returns the one to use; `max_delay` caps the result.
229
+
230
+ ```python
231
+ import random
232
+
233
+ result = (attempt(call_service) * 8)(
234
+ delay=0.1,
235
+ backoff=2.0,
236
+ jitter=lambda wait: random.uniform(0, wait), # "full jitter"
237
+ max_delay=5.0,
238
+ catch=(ConnectionError, TimeoutError),
239
+ )
240
+ ```
241
+
242
+ Other common shapes are `lambda w: w / 2 + random.uniform(0, w / 2)` ("equal jitter") and
243
+ `lambda w: w * random.uniform(0.8, 1.2)` (±20%).
244
+
245
+ ### Logging every failure
246
+
247
+ `on_failure` sees each caught error and its number across the whole plan, including the last.
248
+
249
+ ```python
250
+ import logging
251
+
252
+ log = logging.getLogger(__name__)
253
+
254
+ plan = attempt(fetch_rate, primary, "EUR") * 3 + attempt(fetch_rate, mirror, "EUR") * 2
255
+
256
+ rate = plan(
257
+ delay=0.2,
258
+ catch=(OSError, RetryableHTTPError),
259
+ on_failure=lambda error, n: log.warning("attempt %d/%d failed: %r", n, len(plan), error),
260
+ )
261
+ ```
262
+
263
+ ### Building plans from data
264
+
265
+ Plans are values, so ordinary Python builds them. Fall back through a list of mirrors:
266
+
267
+ ```python
268
+ from functools import reduce
269
+ from operator import add
270
+
271
+ MIRRORS = ["https://a.example.com", "https://b.example.com", "https://c.example.com"]
272
+
273
+ plan = reduce(add, (attempt(fetch_rate, url, "EUR") * 2 for url in MIRRORS))
274
+
275
+ len(plan) # 6
276
+ ```
277
+
278
+ Or rotate through sources instead of exhausting each one first. Multiplying a multi-segment
279
+ plan repeats the whole sequence, like a tuple:
280
+
281
+ ```python
282
+ rotation = (attempt(fetch_rate, MIRRORS[0], "EUR") + attempt(fetch_rate, MIRRORS[1], "EUR")) * 3
283
+ # a, b, a, b, a, b
284
+ ```
285
+
286
+ ### Reusable fragments
287
+
288
+ Name the parts once and combine them where they're used:
289
+
290
+ ```python
291
+ from_api = attempt(load_user_from_api, user_id) * 3
292
+ from_cache = attempt(load_user_from_cache, user_id)
293
+ anonymous = attempt(lambda: ANONYMOUS_USER)
294
+
295
+ strict = from_api # must come from the API, or raise
296
+ relaxed = from_api + from_cache + anonymous # always returns a user
297
+
298
+ user = relaxed(delay=0.1, catch=(OSError, CacheMiss))
299
+ ```
300
+
301
+ ### Waiting for a service to come up
302
+
303
+ Any callable works, including standard library functions with arguments:
304
+
305
+ ```python
306
+ import socket
307
+
308
+ connection = (attempt(socket.create_connection, ("db.internal", 5432), timeout=2) * 10)(
309
+ delay=0.5,
310
+ backoff=1.5,
311
+ max_delay=5.0,
312
+ catch=(OSError,),
313
+ )
314
+ ```
315
+
316
+ ### Failing fast on bugs
317
+
318
+ Only the errors in `catch` are retried. Everything else, like a bug in your parsing code,
319
+ propagates on the first try, unwrapped, with its original traceback:
320
+
321
+ ```python
322
+ def fetch_and_parse() -> Order:
323
+ payload = fetch_order() # may raise ConnectionError: retried
324
+ return Order.from_json(payload) # may raise KeyError: a bug, raised at once
325
+
326
+
327
+ order = (attempt(fetch_and_parse) * 5)(catch=(ConnectionError,))
328
+ ```
329
+
330
+ `catch=()` retries nothing, and every error propagates at once. `catch` never accepts
331
+ `BaseException`, so Ctrl-C always stops the run.
332
+
333
+ ### Handling the failures by type
334
+
335
+ When every attempt fails, `except*` lets you handle each kind of error separately:
336
+
337
+ ```python
338
+ try:
339
+ rate = plan(catch=(urllib.error.URLError, RetryableHTTPError))
340
+ except* RetryableHTTPError as group:
341
+ codes = [error.args[0] for error in group.exceptions]
342
+ log.error("server kept failing: %s", codes)
343
+ rate = None
344
+ except* urllib.error.URLError:
345
+ log.error("network unreachable")
346
+ rate = None
347
+ ```
348
+
349
+ Or catch the whole group and inspect it:
350
+
351
+ ```python
352
+ try:
353
+ rate = plan(catch=(OSError,))
354
+ except ExceptionGroup as group:
355
+ last = group.exceptions[-1]
356
+ timeouts = group.subgroup(TimeoutError)
357
+ ```
358
+
359
+ ## Testing
360
+
361
+ Pass a fake `sleep` so tests run instantly and you can assert on the waits:
362
+
363
+ ```python
364
+ waits = []
365
+ plan(delay=0.05, backoff=2.0, sleep=waits.append)
366
+ assert waits == [0.05, 0.1]
367
+ ```
368
+
369
+ A scripted fake makes each attempt's outcome explicit:
370
+
371
+ ```python
372
+ import pytest
373
+
374
+ from retrpy import attempt
375
+
376
+
377
+ class Scripted:
378
+ """Returns or raises each outcome in turn; the last one repeats."""
379
+
380
+ def __init__(self, *outcomes):
381
+ self.outcomes, self.calls = outcomes, 0
382
+
383
+ def __call__(self):
384
+ outcome = self.outcomes[min(self.calls, len(self.outcomes) - 1)]
385
+ self.calls += 1
386
+ if isinstance(outcome, BaseException):
387
+ raise outcome
388
+ return outcome
389
+
390
+
391
+ def test_falls_back_to_mirror():
392
+ primary = Scripted(ConnectionError("down"))
393
+ mirror = Scripted(ConnectionError("busy"), 1.08)
394
+ waits = []
395
+
396
+ plan = attempt(primary) * 3 + attempt(mirror) * 2
397
+ rate = plan(delay=0.1, backoff=2.0, catch=(ConnectionError,), sleep=waits.append)
398
+
399
+ assert rate == 1.08
400
+ assert (primary.calls, mirror.calls) == (3, 2)
401
+ assert waits == [0.1, 0.2, 0.1]
402
+
403
+
404
+ def test_gives_up_with_every_error():
405
+ plan = attempt(Scripted(ConnectionError("down"))) * 2
406
+
407
+ with pytest.raises(ExceptionGroup, match="all 2 attempts failed") as excinfo:
408
+ plan(catch=(ConnectionError,), sleep=lambda _: None)
409
+
410
+ assert len(excinfo.value.exceptions) == 2
411
+ ```
412
+
413
+ ## With pyflowstep
414
+
415
+ A pyflowstep `Flow` is a callable, so it can be an attempt as is:
416
+
417
+ ```python
418
+ plan = attempt(login_flow, page, user=user) * 3 + attempt(sso_login_flow, page)
419
+ page = plan(delay=0.5, catch=(TimeoutError,))
420
+ ```
@@ -0,0 +1,7 @@
1
+ retrpy/__init__.py,sha256=g32unggFiM8dK9XI25I5lxKbspg-_5vUvSpN2BDDBAc,154
2
+ retrpy/_plan.py,sha256=kAd2Edhl3vO4Y9Da1gKFrAbqMHHvyzCv_to6lVElmco,5260
3
+ retrpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ retrpy-0.1.0.dist-info/METADATA,sha256=jvTukQzf6_SrqF_eZQ_F8rc460bUfq5P5mrtFeASULE,13201
5
+ retrpy-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
6
+ retrpy-0.1.0.dist-info/licenses/LICENSE,sha256=g_XQX9vngE0IGV358UPmNFt3BBiADx5Oajrl5LZLREo,1065
7
+ retrpy-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aaltatan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.