dycw-utilities 0.131.4__py3-none-any.whl → 0.131.5__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.4.dist-info → dycw_utilities-0.131.5.dist-info}/METADATA +1 -1
- {dycw_utilities-0.131.4.dist-info → dycw_utilities-0.131.5.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/hypothesis.py +24 -3
- utilities/whenever2.py +29 -2
- {dycw_utilities-0.131.4.dist-info → dycw_utilities-0.131.5.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.131.4.dist-info → dycw_utilities-0.131.5.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=MtzNC7sc7Go6N1zP7sgvZHDH3FNWCXCzEukoDNvyfZk,60
|
2
2
|
utilities/aiolimiter.py,sha256=mD0wEiqMgwpty4XTbawFpnkkmJS6R4JRsVXFUaoitSU,628
|
3
3
|
utilities/altair.py,sha256=HeZBVUocjkrTNwwKrClppsIqgNFF-ykv05HfZSoHYno,9104
|
4
4
|
utilities/asyncio.py,sha256=lvdgBhuMtxq0dpiwF9g2WMMrit3kqXibN1V5NZ4xdbo,38046
|
@@ -24,7 +24,7 @@ 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=kTxXlZJyBauO3jurT7nIFWXhhmlamUvsNf65OQFEpEc,48084
|
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
|
@@ -88,10 +88,10 @@ 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=jS31ZAY5OMxFxLja_Yo5Fidi87Pd-GoVZ7Vi_teqVDA,16743
|
91
|
-
utilities/whenever2.py,sha256=
|
91
|
+
utilities/whenever2.py,sha256=GgfMrRbjGVjQNtuYuGNnPqeGl-DF6EHIFDa2A41k5aQ,4380
|
92
92
|
utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
|
93
93
|
utilities/zoneinfo.py,sha256=tvcgu3QzDxe2suTexi2QzRGpin7VK1TjHa0JYYxT69I,1862
|
94
|
-
dycw_utilities-0.131.
|
95
|
-
dycw_utilities-0.131.
|
96
|
-
dycw_utilities-0.131.
|
97
|
-
dycw_utilities-0.131.
|
94
|
+
dycw_utilities-0.131.5.dist-info/METADATA,sha256=eVaJ0DASMuOtpOWJ1UFB5YlCame2VQKXPir1EZs9Ebw,1584
|
95
|
+
dycw_utilities-0.131.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
96
|
+
dycw_utilities-0.131.5.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
97
|
+
dycw_utilities-0.131.5.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/hypothesis.py
CHANGED
@@ -47,7 +47,7 @@ from hypothesis.strategies import (
|
|
47
47
|
uuids,
|
48
48
|
)
|
49
49
|
from hypothesis.utils.conventions import not_set
|
50
|
-
from whenever import Date, DateDelta
|
50
|
+
from whenever import Date, DateDelta
|
51
51
|
|
52
52
|
from utilities.datetime import (
|
53
53
|
DATETIME_MAX_NAIVE,
|
@@ -97,7 +97,7 @@ if TYPE_CHECKING:
|
|
97
97
|
|
98
98
|
from hypothesis.database import ExampleDatabase
|
99
99
|
from numpy.random import RandomState
|
100
|
-
from whenever import ZonedDateTime
|
100
|
+
from whenever import PlainDateTime, ZonedDateTime
|
101
101
|
|
102
102
|
from utilities.numpy import NDArrayB, NDArrayF, NDArrayI, NDArrayO
|
103
103
|
from utilities.types import Duration, Number, RoundMode, TimeZoneLike
|
@@ -167,9 +167,15 @@ def date_deltas_whenever(
|
|
167
167
|
*,
|
168
168
|
min_value: MaybeSearchStrategy[DateDelta | None] = None,
|
169
169
|
max_value: MaybeSearchStrategy[DateDelta | None] = None,
|
170
|
+
parsable: MaybeSearchStrategy[bool] = False,
|
170
171
|
) -> DateDelta:
|
171
172
|
"""Strategy for generating date deltas."""
|
172
|
-
from utilities.whenever2 import
|
173
|
+
from utilities.whenever2 import (
|
174
|
+
DATE_DELTA_MAX,
|
175
|
+
DATE_DELTA_MIN,
|
176
|
+
DATE_DELTA_PARSABLE_MAX,
|
177
|
+
DATE_DELTA_PARSABLE_MIN,
|
178
|
+
)
|
173
179
|
|
174
180
|
min_value_, max_value_ = [draw2(draw, v) for v in [min_value, max_value]]
|
175
181
|
match min_value_:
|
@@ -192,6 +198,19 @@ def date_deltas_whenever(
|
|
192
198
|
max_years, max_months, max_days = max_value_.in_years_months_days()
|
193
199
|
assert max_years == 0
|
194
200
|
assert max_months == 0
|
201
|
+
if draw2(draw, parsable):
|
202
|
+
parsable_min_years, parsable_min_months, parsable_min_days = (
|
203
|
+
DATE_DELTA_PARSABLE_MIN.in_years_months_days()
|
204
|
+
)
|
205
|
+
assert parsable_min_years == 0
|
206
|
+
assert parsable_min_months == 0
|
207
|
+
min_days = max(min_days, parsable_min_days)
|
208
|
+
parsable_max_years, parsable_max_months, parsable_max_days = (
|
209
|
+
DATE_DELTA_PARSABLE_MAX.in_years_months_days()
|
210
|
+
)
|
211
|
+
assert parsable_max_years == 0
|
212
|
+
assert parsable_max_months == 0
|
213
|
+
max_days = min(max_days, parsable_max_days)
|
195
214
|
days = draw(integers(min_value=min_days, max_value=max_days))
|
196
215
|
return DateDelta(days=days)
|
197
216
|
|
@@ -1050,6 +1069,8 @@ def plain_datetimes_whenever(
|
|
1050
1069
|
max_value: MaybeSearchStrategy[PlainDateTime | None] = None,
|
1051
1070
|
) -> PlainDateTime:
|
1052
1071
|
"""Strategy for generating plain datetimes."""
|
1072
|
+
from whenever import PlainDateTime
|
1073
|
+
|
1053
1074
|
from utilities.whenever2 import PLAIN_DATE_TIME_MAX, PLAIN_DATE_TIME_MIN
|
1054
1075
|
|
1055
1076
|
min_value_, max_value_ = [draw2(draw, v) for v in [min_value, max_value]]
|
utilities/whenever2.py
CHANGED
@@ -7,10 +7,11 @@ from typing import TYPE_CHECKING, Any, override
|
|
7
7
|
|
8
8
|
from whenever import Date, DateTimeDelta, PlainDateTime, ZonedDateTime
|
9
9
|
|
10
|
-
from utilities.tzlocal import LOCAL_TIME_ZONE
|
11
10
|
from utilities.zoneinfo import UTC, get_time_zone_name
|
12
11
|
|
13
12
|
if TYPE_CHECKING:
|
13
|
+
from zoneinfo import ZoneInfo
|
14
|
+
|
14
15
|
from utilities.types import TimeZoneLike
|
15
16
|
|
16
17
|
|
@@ -27,6 +28,11 @@ DATE_DELTA_MAX = DATE_TIME_DELTA_MAX.date_part()
|
|
27
28
|
TIME_DELTA_MIN = DATE_TIME_DELTA_MIN.time_part()
|
28
29
|
TIME_DELTA_MAX = DATE_TIME_DELTA_MAX.time_part()
|
29
30
|
|
31
|
+
DATE_TIME_DELTA_PARSABLE_MIN = DateTimeDelta(days=-999999)
|
32
|
+
DATE_TIME_DELTA_PARSABLE_MAX = DateTimeDelta(days=999999)
|
33
|
+
DATE_DELTA_PARSABLE_MIN = DATE_TIME_DELTA_PARSABLE_MIN.date_part()
|
34
|
+
DATE_DELTA_PARSABLE_MAX = DATE_TIME_DELTA_PARSABLE_MAX.date_part()
|
35
|
+
|
30
36
|
|
31
37
|
##
|
32
38
|
|
@@ -88,7 +94,24 @@ class WheneverLogRecord(LogRecord):
|
|
88
94
|
)
|
89
95
|
length = self._get_length()
|
90
96
|
plain = format(get_now_local().to_plain().format_common_iso(), f"{length}s")
|
91
|
-
|
97
|
+
time_zone = self._get_time_zone_key()
|
98
|
+
self.zoned_datetime = f"{plain}[{time_zone}]"
|
99
|
+
|
100
|
+
@classmethod
|
101
|
+
@cache
|
102
|
+
def _get_time_zone(cls) -> ZoneInfo:
|
103
|
+
"""Get the local timezone."""
|
104
|
+
try:
|
105
|
+
from utilities.tzlocal import get_local_time_zone
|
106
|
+
except ModuleNotFoundError: # pragma: no cover
|
107
|
+
return UTC
|
108
|
+
return get_local_time_zone()
|
109
|
+
|
110
|
+
@classmethod
|
111
|
+
@cache
|
112
|
+
def _get_time_zone_key(cls) -> str:
|
113
|
+
"""Get the local timezone as a string."""
|
114
|
+
return cls._get_time_zone().key
|
92
115
|
|
93
116
|
@classmethod
|
94
117
|
@cache
|
@@ -101,10 +124,14 @@ class WheneverLogRecord(LogRecord):
|
|
101
124
|
__all__ = [
|
102
125
|
"DATE_DELTA_MAX",
|
103
126
|
"DATE_DELTA_MIN",
|
127
|
+
"DATE_DELTA_PARSABLE_MAX",
|
128
|
+
"DATE_DELTA_PARSABLE_MIN",
|
104
129
|
"DATE_MAX",
|
105
130
|
"DATE_MIN",
|
106
131
|
"DATE_TIME_DELTA_MAX",
|
107
132
|
"DATE_TIME_DELTA_MIN",
|
133
|
+
"DATE_TIME_DELTA_PARSABLE_MAX",
|
134
|
+
"DATE_TIME_DELTA_PARSABLE_MIN",
|
108
135
|
"PLAIN_DATE_TIME_MAX",
|
109
136
|
"PLAIN_DATE_TIME_MIN",
|
110
137
|
"TIME_DELTA_MAX",
|
File without changes
|
File without changes
|