dycw-utilities 0.131.11__py3-none-any.whl → 0.131.13__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.
- {dycw_utilities-0.131.11.dist-info → dycw_utilities-0.131.13.dist-info}/METADATA +1 -1
- {dycw_utilities-0.131.11.dist-info → dycw_utilities-0.131.13.dist-info}/RECORD +21 -21
- utilities/__init__.py +1 -1
- utilities/atools.py +7 -9
- utilities/cachetools.py +8 -10
- utilities/datetime.py +2 -9
- utilities/fastapi.py +2 -4
- utilities/fpdf2.py +2 -2
- utilities/hypothesis.py +0 -136
- utilities/logging.py +54 -52
- utilities/orjson.py +46 -45
- utilities/period.py +86 -256
- utilities/pyinstrument.py +2 -3
- utilities/traceback.py +18 -21
- utilities/typing.py +25 -1
- utilities/tzdata.py +1 -53
- utilities/tzlocal.py +2 -26
- utilities/whenever2.py +15 -2
- utilities/zoneinfo.py +2 -2
- {dycw_utilities-0.131.11.dist-info → dycw_utilities-0.131.13.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.131.11.dist-info → dycw_utilities-0.131.13.dist-info}/licenses/LICENSE +0 -0
@@ -1,10 +1,10 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=3uDzFx7UMHsyNY8dbs9U0P66UUimaERvIAvdIFvrju8,61
|
2
2
|
utilities/aiolimiter.py,sha256=mD0wEiqMgwpty4XTbawFpnkkmJS6R4JRsVXFUaoitSU,628
|
3
3
|
utilities/altair.py,sha256=HeZBVUocjkrTNwwKrClppsIqgNFF-ykv05HfZSoHYno,9104
|
4
4
|
utilities/asyncio.py,sha256=yfKvAIDCRrWdyQMVZMo4DJQx4nVrXoAcqwhNuF95Ryo,38186
|
5
5
|
utilities/atomicwrites.py,sha256=geFjn9Pwn-tTrtoGjDDxWli9NqbYfy3gGL6ZBctiqSo,5393
|
6
|
-
utilities/atools.py,sha256
|
7
|
-
utilities/cachetools.py,sha256=
|
6
|
+
utilities/atools.py,sha256=-bFGIrwYMFR7xl39j02DZMsO_u5x5_Ph7bRlBUFVYyw,1048
|
7
|
+
utilities/cachetools.py,sha256=uBtEv4hD-TuCPX_cQy1lOpLF-QqfwnYGSf0o4Soqydc,2826
|
8
8
|
utilities/click.py,sha256=8gRYeyu9KQ3uim0UpC8VnFnOOKD3DyGwMJ7k0Qns1lM,14659
|
9
9
|
utilities/concurrent.py,sha256=s2scTEd2AhXVTW4hpASU2qxV_DiVLALfms55cCQzCvM,2886
|
10
10
|
utilities/contextlib.py,sha256=lpaLJBy3X0UGLWjM98jkQZZq8so4fRmoK-Bheq0uOW4,1027
|
@@ -12,19 +12,19 @@ utilities/contextvars.py,sha256=RsSGGrbQqqZ67rOydnM7WWIsM2lIE31UHJLejnHJPWY,505
|
|
12
12
|
utilities/cryptography.py,sha256=_CiK_K6c_-uQuUhsUNjNjTL-nqxAh4_1zTfS11Xe120,972
|
13
13
|
utilities/cvxpy.py,sha256=Rv1-fD-XYerosCavRF8Pohop2DBkU3AlFaGTfD8AEAA,13776
|
14
14
|
utilities/dataclasses.py,sha256=iiC1wpGXWhaocIikzwBt8bbLWyImoUlOlcDZJGejaIg,33011
|
15
|
-
utilities/datetime.py,sha256=
|
15
|
+
utilities/datetime.py,sha256=uPQdUgJJ9KuF-pogjYRbI9lOK-i5UBzPHexWe4pOVEo,38713
|
16
16
|
utilities/enum.py,sha256=HoRwVCWzsnH0vpO9ZEcAAIZLMv0Sn2vJxxA4sYMQgDs,5793
|
17
17
|
utilities/errors.py,sha256=nC7ZYtxxDBMfrTHtT_MByBfup_wfGQFRo3eDt-0ZPe8,1045
|
18
18
|
utilities/eventkit.py,sha256=6M5Xu1SzN-juk9PqBHwy5dS-ta7T0qA6SMpDsakOJ0E,13039
|
19
|
-
utilities/fastapi.py,sha256=
|
20
|
-
utilities/fpdf2.py,sha256=
|
19
|
+
utilities/fastapi.py,sha256=zDNPgfYNTZWQfS87y8ekgoJvTvmq07gv5m5kOyMYoX8,2796
|
20
|
+
utilities/fpdf2.py,sha256=PQysO4BcSMRpg-h-t2Pm7yatyk2yFl1inkvtKs1NG4M,1853
|
21
21
|
utilities/functions.py,sha256=jgt592voaHNtX56qX0SRvFveVCRmSIxCZmqvpLZCnY8,27305
|
22
22
|
utilities/functools.py,sha256=WrpHt7NLNWSUn9A1Q_ZIWlNaYZOEI4IFKyBG9HO3BC4,1643
|
23
23
|
utilities/getpass.py,sha256=DfN5UgMAtFCqS3dSfFHUfqIMZX2shXvwphOz_6J6f6A,103
|
24
24
|
utilities/git.py,sha256=oi7-_l5e9haSANSCvQw25ufYGoNahuUPHAZ6114s3JQ,1191
|
25
25
|
utilities/hashlib.py,sha256=SVTgtguur0P4elppvzOBbLEjVM3Pea0eWB61yg2ilxo,309
|
26
26
|
utilities/http.py,sha256=WcahTcKYRtZ04WXQoWt5EGCgFPcyHD3EJdlMfxvDt-0,946
|
27
|
-
utilities/hypothesis.py,sha256=
|
27
|
+
utilities/hypothesis.py,sha256=3mZbEhs5yTcigV2N8PSBqe8pdg2JOYf6e5XOwgGAwjQ,45206
|
28
28
|
utilities/importlib.py,sha256=mV1xT_O_zt_GnZZ36tl3xOmMaN_3jErDWY54fX39F6Y,429
|
29
29
|
utilities/inflect.py,sha256=DbqB5Q9FbRGJ1NbvEiZBirRMxCxgrz91zy5jCO9ZIs0,347
|
30
30
|
utilities/ipython.py,sha256=V2oMYHvEKvlNBzxDXdLvKi48oUq2SclRg5xasjaXStw,763
|
@@ -32,7 +32,7 @@ utilities/iterables.py,sha256=mDqw2_0MUVp-P8FklgcaVTi2TXduH0MxbhTDzzhSBho,44915
|
|
32
32
|
utilities/jupyter.py,sha256=ft5JA7fBxXKzP-L9W8f2-wbF0QeYc_2uLQNFDVk4Z-M,2917
|
33
33
|
utilities/libcst.py,sha256=Jto5ppzRzsxn4AD32IS8n0lbgLYXwsVJB6EY8giNZyY,4974
|
34
34
|
utilities/lightweight_charts.py,sha256=JrkrAZMo6JID2Eoc9QCc05Y_pK4l2zsApIhmii1z2Ig,2764
|
35
|
-
utilities/logging.py,sha256=
|
35
|
+
utilities/logging.py,sha256=zm5k0Cduxtx2H2o7odxUTJtPNkJS85mqHYN1cS5Kc1w,17863
|
36
36
|
utilities/luigi.py,sha256=fpH9MbxJDuo6-k9iCXRayFRtiVbUtibCJKugf7ygpv0,5988
|
37
37
|
utilities/math.py,sha256=_6vrDyjtaqE_OFE-F2DNWrDG_J_kMl3nFAJsok9v_bY,26862
|
38
38
|
utilities/memory_profiler.py,sha256=tf2C51P2lCujPGvRt2Rfc7VEw5LDXmVPCG3z_AvBmbU,962
|
@@ -41,11 +41,11 @@ utilities/more_itertools.py,sha256=tBbjjKx8_Uv_TCjxhPwrGfAx_jRHtvLIZqXVWAsjzqA,8
|
|
41
41
|
utilities/numpy.py,sha256=Xn23sA2ZbVNqwUYEgNJD3XBYH6IbCri_WkHSNhg3NkY,26122
|
42
42
|
utilities/operator.py,sha256=0M2yZJ0PODH47ogFEnkGMBe_cfxwZR02T_92LZVZvHo,3715
|
43
43
|
utilities/optuna.py,sha256=loyJGWTzljgdJaoLhP09PT8Jz6o_pwBOwehY33lHkhw,1923
|
44
|
-
utilities/orjson.py,sha256=
|
44
|
+
utilities/orjson.py,sha256=lhBSO-QCm2g-uhUE0hKe-PVhAt1TKRRx0iZLSFPmew4,36970
|
45
45
|
utilities/os.py,sha256=D_FyyT-6TtqiN9KSS7c9g1fnUtgxmyMtzAjmYLkk46A,3587
|
46
46
|
utilities/parse.py,sha256=vsZ2jf_ceSI_Kta9titixufysJaVXh0Whjz1T4awJZw,18938
|
47
47
|
utilities/pathlib.py,sha256=PK41rf1c9Wqv7h8f5R7H3_Lhq_gQZTUJD5tu3gMHVaU,3247
|
48
|
-
utilities/period.py,sha256=
|
48
|
+
utilities/period.py,sha256=opqpBevBGSGXbA7NYfRJjtthi1JPxdMaZ7QV3xosnTc,4774
|
49
49
|
utilities/pickle.py,sha256=MBT2xZCsv0pH868IXLGKnlcqNx2IRVKYNpRcqiQQqxw,653
|
50
50
|
utilities/platform.py,sha256=48IOKx1IC6ZJXWG-b56ZQptITcNFhWRjELW72o2dGTA,2398
|
51
51
|
utilities/polars.py,sha256=QlmUpYTqHNkcLnWOQh1TW22W2QyLzvifCvBcbsqhpdE,63272
|
@@ -55,7 +55,7 @@ utilities/pqdm.py,sha256=foRytQybmOQ05pjt5LF7ANyzrIa--4ScDE3T2wd31a4,3118
|
|
55
55
|
utilities/psutil.py,sha256=RtbLKOoIJhqrJmEoHDBVeSD-KPzshtS0FtRXBP9_w2s,3751
|
56
56
|
utilities/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
57
57
|
utilities/pydantic.py,sha256=aP6OKowg2Md4rgQuQ5qTSF4bTbBuq7WtRb7zS3JSRGY,1841
|
58
|
-
utilities/pyinstrument.py,sha256=
|
58
|
+
utilities/pyinstrument.py,sha256=3MPNDbZW_1Aj1aA1_f-yqPStgmjIFxPwIafYq2dsaTs,853
|
59
59
|
utilities/pyrsistent.py,sha256=wVOVIe_68AAaa-lUE9y-TEzDawVp1uEIc_zfoDgr5ww,2287
|
60
60
|
utilities/pytest.py,sha256=zP4CWKXpRVk4aRDRxolUAvqQwX7wgDO8lzmkQfuZaZo,7832
|
61
61
|
utilities/pytest_regressions.py,sha256=YI55B7EtLjhz7zPJZ6NK9bWrxrKCKabWZJe1cwcbA5o,5082
|
@@ -79,19 +79,19 @@ utilities/tenacity.py,sha256=1PUvODiBVgeqIh7G5TRt5WWMSqjLYkEqP53itT97WQc,4914
|
|
79
79
|
utilities/text.py,sha256=ymBFlP_cA8OgNnZRVNs7FAh7OG8HxE6YkiLEMZv5g_A,11297
|
80
80
|
utilities/threading.py,sha256=GvBOp4CyhHfN90wGXZuA2VKe9fGzMaEa7oCl4f3nnPU,1009
|
81
81
|
utilities/timer.py,sha256=VeSl3ot8-f4D1d3HjjSsgKvjxHJGXd_sW4KcTExOR64,2475
|
82
|
-
utilities/traceback.py,sha256=
|
82
|
+
utilities/traceback.py,sha256=cMXrCD59CROnezAU8VW67CxZ8Igc5QmaxlV8qrBvNMs,8504
|
83
83
|
utilities/types.py,sha256=CHQke10ETEpypxppYVhWp1G68S6mvifalrRLolYBcCg,19506
|
84
|
-
utilities/typing.py,sha256=
|
85
|
-
utilities/tzdata.py,sha256=
|
86
|
-
utilities/tzlocal.py,sha256=
|
84
|
+
utilities/typing.py,sha256=VuGuztLSkTicxgVwI5wrVOTcY70OlzwsTU7LcFVjGlY,14169
|
85
|
+
utilities/tzdata.py,sha256=fgNVj66yUbCSI_-vrRVzSD3gtf-L_8IEJEPjP_Jel5Y,266
|
86
|
+
utilities/tzlocal.py,sha256=xbBBzVIUKMk8AkhuIp1qxGRNBioIa5I09dpeoBnIOOU,662
|
87
87
|
utilities/uuid.py,sha256=jJTFxz-CWgltqNuzmythB7iEQ-Q1mCwPevUfKthZT3c,611
|
88
88
|
utilities/version.py,sha256=ufhJMmI6KPs1-3wBI71aj5wCukd3sP_m11usLe88DNA,5117
|
89
89
|
utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
|
90
90
|
utilities/whenever.py,sha256=2NQ-0SnLNW2kFpefP9dVE8H0RbaeusXYLPmv282Jpto,16755
|
91
|
-
utilities/whenever2.py,sha256=
|
91
|
+
utilities/whenever2.py,sha256=iFVL4CjuIOpzsDU6li5smHnDEqam30-FtTgXWeHuWiE,7510
|
92
92
|
utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
|
93
|
-
utilities/zoneinfo.py,sha256=
|
94
|
-
dycw_utilities-0.131.
|
95
|
-
dycw_utilities-0.131.
|
96
|
-
dycw_utilities-0.131.
|
97
|
-
dycw_utilities-0.131.
|
93
|
+
utilities/zoneinfo.py,sha256=gJPr9l7V8s3Y7TXpCGYEM1S81Rplb9e4MoV9Nvy2VU8,1852
|
94
|
+
dycw_utilities-0.131.13.dist-info/METADATA,sha256=BSLseH0v8xkeiTFmvQ2ITtMLy6gHtk6aFRAmuNQEy_k,1585
|
95
|
+
dycw_utilities-0.131.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
96
|
+
dycw_utilities-0.131.13.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
97
|
+
dycw_utilities-0.131.13.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/atools.py
CHANGED
@@ -5,25 +5,22 @@ from typing import TYPE_CHECKING, ParamSpec, TypeVar
|
|
5
5
|
|
6
6
|
from atools import memoize
|
7
7
|
|
8
|
-
from utilities.datetime import datetime_duration_to_timedelta
|
9
8
|
from utilities.types import Coroutine1
|
10
9
|
|
11
10
|
if TYPE_CHECKING:
|
12
|
-
|
13
|
-
|
14
|
-
from utilities.types import Duration
|
11
|
+
from whenever import TimeDelta
|
15
12
|
|
16
13
|
|
17
14
|
_P = ParamSpec("_P")
|
18
15
|
_R = TypeVar("_R")
|
19
16
|
_AsyncFunc = Callable[_P, Coroutine1[_R]]
|
20
|
-
type _Key = tuple[_AsyncFunc,
|
17
|
+
type _Key = tuple[_AsyncFunc, TimeDelta]
|
21
18
|
_MEMOIZED_FUNCS: dict[_Key, _AsyncFunc] = {}
|
22
19
|
|
23
20
|
|
24
21
|
async def call_memoized(
|
25
22
|
func: _AsyncFunc[_P, _R],
|
26
|
-
refresh:
|
23
|
+
refresh: TimeDelta | None = None,
|
27
24
|
/,
|
28
25
|
*args: _P.args,
|
29
26
|
**kwargs: _P.kwargs,
|
@@ -31,13 +28,14 @@ async def call_memoized(
|
|
31
28
|
"""Call an asynchronous function, with possible memoization."""
|
32
29
|
if refresh is None:
|
33
30
|
return await func(*args, **kwargs)
|
34
|
-
|
35
|
-
key: _Key = (func, timedelta)
|
31
|
+
key: _Key = (func, refresh)
|
36
32
|
memoized_func: _AsyncFunc[_P, _R]
|
37
33
|
try:
|
38
34
|
memoized_func = _MEMOIZED_FUNCS[key]
|
39
35
|
except KeyError:
|
40
|
-
memoized_func = _MEMOIZED_FUNCS[(key)] = memoize(duration=refresh)(
|
36
|
+
memoized_func = _MEMOIZED_FUNCS[(key)] = memoize(duration=refresh.in_seconds())(
|
37
|
+
func
|
38
|
+
)
|
41
39
|
return await memoized_func(*args, **kwargs)
|
42
40
|
|
43
41
|
|
utilities/cachetools.py
CHANGED
@@ -8,10 +8,10 @@ from typing import TYPE_CHECKING, Any, TypeVar, override
|
|
8
8
|
import cachetools
|
9
9
|
from cachetools.func import ttl_cache
|
10
10
|
|
11
|
-
from utilities.datetime import datetime_duration_to_float
|
12
|
-
|
13
11
|
if TYPE_CHECKING:
|
14
|
-
from
|
12
|
+
from whenever import TimeDelta
|
13
|
+
|
14
|
+
from utilities.types import TCallable
|
15
15
|
|
16
16
|
_K = TypeVar("_K")
|
17
17
|
_T = TypeVar("_T")
|
@@ -25,15 +25,13 @@ class TTLCache(cachetools.TTLCache[_K, _V]):
|
|
25
25
|
self,
|
26
26
|
*,
|
27
27
|
max_size: int | None = None,
|
28
|
-
max_duration:
|
28
|
+
max_duration: TimeDelta | None = None,
|
29
29
|
timer: Callable[[], float] = monotonic,
|
30
30
|
get_size_of: Callable[[Any], int] | None = None,
|
31
31
|
) -> None:
|
32
32
|
super().__init__(
|
33
33
|
maxsize=inf if max_size is None else max_size,
|
34
|
-
ttl=inf
|
35
|
-
if max_duration is None
|
36
|
-
else datetime_duration_to_float(max_duration),
|
34
|
+
ttl=inf if max_duration is None else max_duration.in_seconds(),
|
37
35
|
timer=timer,
|
38
36
|
getsizeof=get_size_of,
|
39
37
|
)
|
@@ -54,7 +52,7 @@ class TTLSet(MutableSet[_T]):
|
|
54
52
|
/,
|
55
53
|
*,
|
56
54
|
max_size: int | None = None,
|
57
|
-
max_duration:
|
55
|
+
max_duration: TimeDelta | None = None,
|
58
56
|
timer: Callable[[], float] = monotonic,
|
59
57
|
get_size_of: Callable[[Any], int] | None = None,
|
60
58
|
) -> None:
|
@@ -103,14 +101,14 @@ class TTLSet(MutableSet[_T]):
|
|
103
101
|
def cache(
|
104
102
|
*,
|
105
103
|
max_size: int | None = None,
|
106
|
-
max_duration:
|
104
|
+
max_duration: TimeDelta | None = None,
|
107
105
|
timer: Callable[[], float] = monotonic,
|
108
106
|
typed_: bool = False,
|
109
107
|
) -> Callable[[TCallable], TCallable]:
|
110
108
|
"""Decorate a function with `max_size` and/or `ttl` settings."""
|
111
109
|
return ttl_cache(
|
112
110
|
maxsize=inf if max_size is None else max_size,
|
113
|
-
ttl=inf if max_duration is None else
|
111
|
+
ttl=inf if max_duration is None else max_duration.in_seconds(),
|
114
112
|
timer=timer,
|
115
113
|
typed=typed_,
|
116
114
|
)
|
utilities/datetime.py
CHANGED
@@ -21,21 +21,14 @@ from utilities.iterables import OneEmptyError, one
|
|
21
21
|
from utilities.math import SafeRoundError, round_, safe_round
|
22
22
|
from utilities.platform import SYSTEM
|
23
23
|
from utilities.sentinel import Sentinel, sentinel
|
24
|
-
from utilities.types import MaybeStr
|
24
|
+
from utilities.types import MaybeCallablePyDate, MaybeCallablePyDateTime, MaybeStr
|
25
25
|
from utilities.typing import is_instance_gen
|
26
26
|
from utilities.zoneinfo import UTC, ensure_time_zone, get_time_zone_name
|
27
27
|
|
28
28
|
if TYPE_CHECKING:
|
29
29
|
from collections.abc import Iterator
|
30
30
|
|
31
|
-
from utilities.types import
|
32
|
-
DateOrDateTime,
|
33
|
-
Duration,
|
34
|
-
MathRoundMode,
|
35
|
-
MaybeCallablePyDate,
|
36
|
-
MaybeCallablePyDateTime,
|
37
|
-
TimeZoneLike,
|
38
|
-
)
|
31
|
+
from utilities.types import DateOrDateTime, Duration, MathRoundMode, TimeZoneLike
|
39
32
|
|
40
33
|
|
41
34
|
_DAYS_PER_YEAR = 365.25
|
utilities/fastapi.py
CHANGED
@@ -9,8 +9,7 @@ from uvicorn import Config, Server
|
|
9
9
|
|
10
10
|
from utilities.asyncio import Looper
|
11
11
|
from utilities.datetime import SECOND, datetime_duration_to_float
|
12
|
-
from utilities.
|
13
|
-
from utilities.whenever import serialize_zoned_datetime # skipif-ci
|
12
|
+
from utilities.whenever2 import get_now_local
|
14
13
|
|
15
14
|
if TYPE_CHECKING:
|
16
15
|
from types import TracebackType
|
@@ -31,8 +30,7 @@ class _PingerReceiverApp(FastAPI):
|
|
31
30
|
|
32
31
|
@self.get("/ping") # skipif-ci
|
33
32
|
def ping() -> str:
|
34
|
-
|
35
|
-
return f"pong @ {now}" # skipif-ci
|
33
|
+
return f"pong @ {get_now_local()}" # skipif-ci
|
36
34
|
|
37
35
|
_ = ping # skipif-ci
|
38
36
|
|
utilities/fpdf2.py
CHANGED
@@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, override
|
|
6
6
|
from fpdf import FPDF
|
7
7
|
from fpdf.enums import XPos, YPos
|
8
8
|
|
9
|
-
from utilities.
|
9
|
+
from utilities.whenever2 import format_compact, get_now
|
10
10
|
|
11
11
|
if TYPE_CHECKING:
|
12
12
|
from collections.abc import Iterator
|
@@ -47,7 +47,7 @@ def yield_pdf(*, header: str | None = None) -> Iterator[_BasePDF]:
|
|
47
47
|
def footer(self) -> None:
|
48
48
|
self.set_y(-15)
|
49
49
|
self.set_font(family="Helvetica", style="I", size=8)
|
50
|
-
page_no, now = self.page_no(),
|
50
|
+
page_no, now = self.page_no(), format_compact(get_now())
|
51
51
|
text = f"page {page_no}/{{}}; {now}"
|
52
52
|
_ = self.cell(
|
53
53
|
w=0,
|
utilities/hypothesis.py
CHANGED
@@ -795,139 +795,6 @@ def min_and_max_datetimes(
|
|
795
795
|
##
|
796
796
|
|
797
797
|
|
798
|
-
@composite
|
799
|
-
def min_and_maybe_max_datetimes(
|
800
|
-
draw: DrawFn,
|
801
|
-
/,
|
802
|
-
*,
|
803
|
-
min_value: MaybeSearchStrategy[dt.datetime | None] = None,
|
804
|
-
max_value: MaybeSearchStrategy[dt.datetime | None | Sentinel] = sentinel,
|
805
|
-
time_zone: MaybeSearchStrategy[ZoneInfo | timezone] = UTC,
|
806
|
-
round_: MathRoundMode | None = None,
|
807
|
-
timedelta: dt.timedelta | None = None,
|
808
|
-
rel_tol: float | None = None,
|
809
|
-
abs_tol: float | None = None,
|
810
|
-
valid: bool = False,
|
811
|
-
) -> tuple[dt.datetime, dt.datetime | None]:
|
812
|
-
match min_value, max_value:
|
813
|
-
case None, Sentinel():
|
814
|
-
min_value_, max_value_ = draw(
|
815
|
-
pairs(
|
816
|
-
zoned_datetimes(
|
817
|
-
time_zone=time_zone,
|
818
|
-
round_=round_,
|
819
|
-
timedelta=timedelta,
|
820
|
-
rel_tol=rel_tol,
|
821
|
-
abs_tol=abs_tol,
|
822
|
-
valid=valid,
|
823
|
-
),
|
824
|
-
sorted=True,
|
825
|
-
)
|
826
|
-
)
|
827
|
-
return min_value_, draw(just(max_value_) | none())
|
828
|
-
case None, None:
|
829
|
-
min_value_ = draw(
|
830
|
-
zoned_datetimes(
|
831
|
-
time_zone=time_zone,
|
832
|
-
round_=round_,
|
833
|
-
timedelta=timedelta,
|
834
|
-
rel_tol=rel_tol,
|
835
|
-
abs_tol=abs_tol,
|
836
|
-
valid=valid,
|
837
|
-
)
|
838
|
-
)
|
839
|
-
return min_value_, None
|
840
|
-
case None, dt.datetime():
|
841
|
-
min_value_ = draw(
|
842
|
-
zoned_datetimes(
|
843
|
-
max_value=max_value,
|
844
|
-
time_zone=time_zone,
|
845
|
-
round_=round_,
|
846
|
-
timedelta=timedelta,
|
847
|
-
rel_tol=rel_tol,
|
848
|
-
abs_tol=abs_tol,
|
849
|
-
valid=valid,
|
850
|
-
)
|
851
|
-
)
|
852
|
-
return min_value_, max_value
|
853
|
-
case dt.datetime(), Sentinel():
|
854
|
-
max_value_ = draw(
|
855
|
-
zoned_datetimes(
|
856
|
-
min_value=min_value,
|
857
|
-
time_zone=time_zone,
|
858
|
-
round_=round_,
|
859
|
-
timedelta=timedelta,
|
860
|
-
rel_tol=rel_tol,
|
861
|
-
abs_tol=abs_tol,
|
862
|
-
valid=valid,
|
863
|
-
)
|
864
|
-
| none()
|
865
|
-
)
|
866
|
-
return min_value, max_value_
|
867
|
-
case dt.datetime(), None:
|
868
|
-
return min_value, None
|
869
|
-
case dt.datetime(), dt.datetime():
|
870
|
-
_ = assume(min_value <= max_value)
|
871
|
-
return min_value, max_value
|
872
|
-
case _, _:
|
873
|
-
strategy = zoned_datetimes(
|
874
|
-
time_zone=time_zone,
|
875
|
-
round_=round_,
|
876
|
-
timedelta=timedelta,
|
877
|
-
rel_tol=rel_tol,
|
878
|
-
abs_tol=abs_tol,
|
879
|
-
valid=valid,
|
880
|
-
)
|
881
|
-
min_value_ = draw2(draw, min_value, strategy)
|
882
|
-
max_value_ = draw2(draw, max_value, strategy | none(), sentinel=True)
|
883
|
-
_ = assume((max_value_ is None) or (min_value_ <= max_value_))
|
884
|
-
return min_value_, max_value_
|
885
|
-
case _ as never:
|
886
|
-
assert_never(never)
|
887
|
-
|
888
|
-
|
889
|
-
##
|
890
|
-
|
891
|
-
|
892
|
-
@composite
|
893
|
-
def min_and_maybe_max_sizes(
|
894
|
-
draw: DrawFn,
|
895
|
-
/,
|
896
|
-
*,
|
897
|
-
min_value: MaybeSearchStrategy[int | None] = None,
|
898
|
-
max_value: MaybeSearchStrategy[int | None | Sentinel] = sentinel,
|
899
|
-
) -> tuple[int, int | None]:
|
900
|
-
match min_value, max_value:
|
901
|
-
case None, Sentinel():
|
902
|
-
min_value_, max_value_ = draw(pairs(integers(min_value=0), sorted=True))
|
903
|
-
return min_value_, draw(just(max_value_) | none())
|
904
|
-
case None, None:
|
905
|
-
min_value_ = draw(integers(min_value=0))
|
906
|
-
return min_value_, None
|
907
|
-
case None, int():
|
908
|
-
min_value_ = draw(integers(0, max_value))
|
909
|
-
return min_value_, max_value
|
910
|
-
case int(), Sentinel():
|
911
|
-
max_value_ = draw(integers(min_value=min_value) | none())
|
912
|
-
return min_value, max_value_
|
913
|
-
case int(), None:
|
914
|
-
return min_value, None
|
915
|
-
case int(), int():
|
916
|
-
_ = assume(min_value <= max_value)
|
917
|
-
return min_value, max_value
|
918
|
-
case _, _:
|
919
|
-
strategy = integers(min_value=0)
|
920
|
-
min_value_ = draw2(draw, min_value, strategy)
|
921
|
-
max_value_ = draw2(draw, max_value, strategy | none(), sentinel=True)
|
922
|
-
_ = assume((max_value_ is None) or (min_value_ <= max_value_))
|
923
|
-
return min_value_, max_value_
|
924
|
-
case _ as never:
|
925
|
-
assert_never(never)
|
926
|
-
|
927
|
-
|
928
|
-
##
|
929
|
-
|
930
|
-
|
931
798
|
@composite
|
932
799
|
def months(
|
933
800
|
draw: DrawFn,
|
@@ -1695,9 +1562,6 @@ __all__ = [
|
|
1695
1562
|
"int_arrays",
|
1696
1563
|
"lists_fixed_length",
|
1697
1564
|
"min_and_max_datetimes",
|
1698
|
-
"min_and_maybe_max_datetimes",
|
1699
|
-
"min_and_maybe_max_sizes",
|
1700
|
-
"min_and_maybe_max_sizes",
|
1701
1565
|
"months",
|
1702
1566
|
"namespace_mixins",
|
1703
1567
|
"numbers",
|