dycw-utilities 0.125.4__py3-none-any.whl → 0.125.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.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-utilities
3
- Version: 0.125.4
3
+ Version: 0.125.5
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
7
7
  Requires-Dist: typing-extensions<4.14,>=4.13.1
8
8
  Provides-Extra: test
9
- Requires-Dist: hypothesis<6.132,>=6.131.27; extra == 'test'
9
+ Requires-Dist: hypothesis<6.132,>=6.131.28; extra == 'test'
10
10
  Requires-Dist: pytest-asyncio<0.27,>=0.26.0; extra == 'test'
11
11
  Requires-Dist: pytest-cov<6.2,>=6.1.1; extra == 'test'
12
12
  Requires-Dist: pytest-instafail<0.6,>=0.5.0; extra == 'test'
@@ -41,7 +41,7 @@ Requires-Dist: whenever<0.9,>=0.8.2; extra == 'zzz-test-click'
41
41
  Provides-Extra: zzz-test-contextlib
42
42
  Provides-Extra: zzz-test-contextvars
43
43
  Provides-Extra: zzz-test-cryptography
44
- Requires-Dist: cryptography<45.1,>=45.0.2; extra == 'zzz-test-cryptography'
44
+ Requires-Dist: cryptography<45.1,>=45.0.3; extra == 'zzz-test-cryptography'
45
45
  Provides-Extra: zzz-test-cvxpy
46
46
  Requires-Dist: cvxpy<1.7,>=1.6.5; extra == 'zzz-test-cvxpy'
47
47
  Provides-Extra: zzz-test-dataclasses
@@ -78,7 +78,7 @@ Provides-Extra: zzz-test-hypothesis
78
78
  Requires-Dist: aiosqlite<0.22,>=0.21.0; extra == 'zzz-test-hypothesis'
79
79
  Requires-Dist: asyncpg<0.31,>=0.30.0; extra == 'zzz-test-hypothesis'
80
80
  Requires-Dist: greenlet<3.3,>=3.2.0; extra == 'zzz-test-hypothesis'
81
- Requires-Dist: hypothesis<6.132,>=6.131.27; extra == 'zzz-test-hypothesis'
81
+ Requires-Dist: hypothesis<6.132,>=6.131.28; extra == 'zzz-test-hypothesis'
82
82
  Requires-Dist: luigi<3.7,>=3.6.0; extra == 'zzz-test-hypothesis'
83
83
  Requires-Dist: numpy<2.3,>=2.2.6; extra == 'zzz-test-hypothesis'
84
84
  Requires-Dist: pathvalidate<3.3,>=3.2.3; extra == 'zzz-test-hypothesis'
@@ -1,4 +1,4 @@
1
- utilities/__init__.py,sha256=O9WCgPzIqylIlRxvuTI9h_FJzryWHiUMdYDZGV6Rhj8,60
1
+ utilities/__init__.py,sha256=DteTSv79-JnoG5SiUi0i4Es8z2F38hAIDg1-tlzG4mc,60
2
2
  utilities/altair.py,sha256=Gpja-flOo-Db0PIPJLJsgzAlXWoKUjPU1qY-DQ829ek,9156
3
3
  utilities/asyncio.py,sha256=gr2eUx0E6LiCup6VKgUGwh8lAUriGdX2TlK-PZdlvfo,28284
4
4
  utilities/atomicwrites.py,sha256=geFjn9Pwn-tTrtoGjDDxWli9NqbYfy3gGL6ZBctiqSo,5393
@@ -26,10 +26,10 @@ utilities/http.py,sha256=WcahTcKYRtZ04WXQoWt5EGCgFPcyHD3EJdlMfxvDt-0,946
26
26
  utilities/hypothesis.py,sha256=a75izXg9aCBhhDkj_ZgK3TDzlzk38evP8TO7JbYYQvg,46264
27
27
  utilities/importlib.py,sha256=mV1xT_O_zt_GnZZ36tl3xOmMaN_3jErDWY54fX39F6Y,429
28
28
  utilities/ipython.py,sha256=V2oMYHvEKvlNBzxDXdLvKi48oUq2SclRg5xasjaXStw,763
29
- utilities/iterables.py,sha256=prKXBdF5QfLTGC-q4567DwO8xzUng_Z-2a4wBkMqyDo,45360
29
+ utilities/iterables.py,sha256=wqq2lKfEAq1qncE-lR848DHX627aerFaq4BXmLen-NE,43589
30
30
  utilities/jupyter.py,sha256=ft5JA7fBxXKzP-L9W8f2-wbF0QeYc_2uLQNFDVk4Z-M,2917
31
- utilities/libcst.py,sha256=jGLm2vTwUFcCIghN66mDSUXesgZZ6Pw2BbixkUf-PHA,5062
32
- utilities/lightweight_charts.py,sha256=vyVOzarYhBIOZj2xDhqdbP85qbSKUjdc6Au91rc1W4M,2814
31
+ utilities/libcst.py,sha256=zqZxfvTdcsi83Ph-HC4lP8zyOqAun7eKABeRdhMtoMM,4846
32
+ utilities/lightweight_charts.py,sha256=0xNfcsrgFI0R9xL25LtSm-W5yhfBI93qQNT6HyaXAhg,2769
33
33
  utilities/logging.py,sha256=gwo3pusPjnWO1ollrtn1VKYyRAQJTue4SkCbMeNvec4,25715
34
34
  utilities/loguru.py,sha256=MEMQVWrdECxk1e3FxGzmOf21vWT9j8CAir98SEXFKPA,3809
35
35
  utilities/luigi.py,sha256=fpH9MbxJDuo6-k9iCXRayFRtiVbUtibCJKugf7ygpv0,5988
@@ -47,14 +47,14 @@ utilities/pathlib.py,sha256=31WPMXdLIyXgYOMMl_HOI2wlo66MGSE-cgeelk-Lias,1410
47
47
  utilities/period.py,sha256=o4wXYEXVlFomop4-Ra4L0yRP4i99NZFjIe_fa7NdZck,11024
48
48
  utilities/pickle.py,sha256=Bhvd7cZl-zQKQDFjUerqGuSKlHvnW1K2QXeU5UZibtg,657
49
49
  utilities/platform.py,sha256=NU7ycTvAXAG-fdYmDXaM1m4EOml2cGiaYwaUzfzSqyU,1767
50
- utilities/polars.py,sha256=tGO3r6S4lFtir6zbdIvZ_kvKBWIha4lnA1eEmV3EvNQ,63632
51
- utilities/polars_ols.py,sha256=efhXf0gjrHUpQrvS6a7g8yJQJWf_ATKtJnqqF2inCOU,5680
50
+ utilities/polars.py,sha256=QlmUpYTqHNkcLnWOQh1TW22W2QyLzvifCvBcbsqhpdE,63272
51
+ utilities/polars_ols.py,sha256=Uc9V5kvlWZ5cU93lKZ-cfAKdVFFw81tqwLW9PxtUvMs,5618
52
52
  utilities/pqdm.py,sha256=foRytQybmOQ05pjt5LF7ANyzrIa--4ScDE3T2wd31a4,3118
53
53
  utilities/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  utilities/pydantic.py,sha256=f6qtR5mO2YMuyvNmbaEj5YeD9eGA4YYfb7Bjzh9jUs0,1845
55
55
  utilities/pyinstrument.py,sha256=OJFDh4o1CWIa4aYPYURdQjgap_nvP45KUsCEe94rQHY,829
56
- utilities/pyrsistent.py,sha256=MoDcAqQGlSNkmlS32DCJLw-cZFAfHB6K9kpox_iyI4k,2512
57
- utilities/pytest.py,sha256=85QUax4g2VBBAqAHtM9wekcSLB7_9O8AKFTaCshztL8,7989
56
+ utilities/pyrsistent.py,sha256=wVOVIe_68AAaa-lUE9y-TEzDawVp1uEIc_zfoDgr5ww,2287
57
+ utilities/pytest.py,sha256=KoHSwJbIY2CHtFUlUr_gnEk7z1DVTaldl8RDQ4tDkG4,7837
58
58
  utilities/pytest_regressions.py,sha256=-SVT9647Dg6-JcdsiaDKXe3NdOmmrvGevLKWwGjxq3c,5088
59
59
  utilities/python_dotenv.py,sha256=iWcnpXbH7S6RoXHiLlGgyuH6udCupAcPd_gQ0eAenQ0,3190
60
60
  utilities/random.py,sha256=lYdjgxB7GCfU_fwFVl5U-BIM_HV3q6_urL9byjrwDM8,4157
@@ -68,7 +68,7 @@ utilities/shelve.py,sha256=HZsMwK4tcIfg3sh0gApx4-yjQnrY4o3V3ZRimvRhoW0,738
68
68
  utilities/slack_sdk.py,sha256=Q8UakiB7qo6SUfaBDB0j1N4b8MuFzaD9lG5HGq7rtuw,3200
69
69
  utilities/socket.py,sha256=K77vfREvzoVTrpYKo6MZakol0EYu2q1sWJnnZqL0So0,118
70
70
  utilities/sqlalchemy.py,sha256=p8vsHaNRoeq5zJouIKyp9piFM26wtm5yR4DkzCMFDSw,35471
71
- utilities/sqlalchemy_polars.py,sha256=wjJpoUo-yO9E2ujpG_06vV5r2OdvBiQ4yvV6wKCa2Tk,15605
71
+ utilities/sqlalchemy_polars.py,sha256=s7hQNep2O5DTgIRXyN_JRQma7a4DAtNd25tshaZW8iw,15490
72
72
  utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
73
73
  utilities/streamlit.py,sha256=U9PJBaKP1IdSykKhPZhIzSPTZsmLsnwbEPZWzNhJPKk,2955
74
74
  utilities/sys.py,sha256=h0Xr7Vj86wNalvwJVP1wj5Y0kD_VWm1vzuXZ_jw94mE,2743
@@ -88,7 +88,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
88
88
  utilities/whenever.py,sha256=jS31ZAY5OMxFxLja_Yo5Fidi87Pd-GoVZ7Vi_teqVDA,16743
89
89
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
90
90
  utilities/zoneinfo.py,sha256=-5j7IQ9nb7gR43rdgA7ms05im-XuqhAk9EJnQBXxCoQ,1874
91
- dycw_utilities-0.125.4.dist-info/METADATA,sha256=dwOemW5k0Dz8lVM3bRKczDGMMkRNTW41Np8Bi_13dEU,12851
92
- dycw_utilities-0.125.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
- dycw_utilities-0.125.4.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
- dycw_utilities-0.125.4.dist-info/RECORD,,
91
+ dycw_utilities-0.125.5.dist-info/METADATA,sha256=OP9MTsqYyVzlwUsK9XdBKW3Z_5p4PNCNC3K8Io5dyMs,12851
92
+ dycw_utilities-0.125.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
+ dycw_utilities-0.125.5.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
+ dycw_utilities-0.125.5.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.125.4"
3
+ __version__ = "0.125.5"
utilities/iterables.py CHANGED
@@ -25,7 +25,6 @@ from typing import (
25
25
  Any,
26
26
  Generic,
27
27
  Literal,
28
- Self,
29
28
  TypeGuard,
30
29
  TypeVar,
31
30
  assert_never,
@@ -45,7 +44,7 @@ from utilities.math import (
45
44
  )
46
45
  from utilities.reprlib import get_repr
47
46
  from utilities.sentinel import Sentinel, sentinel
48
- from utilities.types import Sign, THashable, THashable2, TSupportsAdd, TSupportsLT
47
+ from utilities.types import Sign, THashable, TSupportsAdd, TSupportsLT
49
48
  from utilities.zoneinfo import UTC
50
49
 
51
50
  if TYPE_CHECKING:
@@ -722,57 +721,6 @@ def chunked(iterable: Iterable[_T], n: int, /) -> Iterator[Sequence[_T]]:
722
721
  ##
723
722
 
724
723
 
725
- class Collection(frozenset[THashable]):
726
- """A collection of hashable, sortable items."""
727
-
728
- def __new__(cls, *item_or_items: MaybeIterable[THashable]) -> Self:
729
- items = list(chain(*map(always_iterable, item_or_items)))
730
- cls.check_items(items)
731
- return super().__new__(cls, items)
732
-
733
- def __init__(self, *item_or_items: MaybeIterable[THashable]) -> None:
734
- super().__init__()
735
- _ = item_or_items
736
-
737
- @override
738
- def __and__(self, other: MaybeIterable[THashable], /) -> Self:
739
- if isinstance(other, type(self)):
740
- return type(self)(super().__and__(other))
741
- return self.__and__(type(self)(other))
742
-
743
- @override
744
- def __or__(self, other: MaybeIterable[THashable], /) -> Self:
745
- if isinstance(other, type(self)):
746
- return type(self)(super().__or__(other))
747
- return self.__or__(type(self)(other))
748
-
749
- @override
750
- def __sub__(self, other: MaybeIterable[THashable], /) -> Self:
751
- if isinstance(other, type(self)):
752
- return type(self)(super().__sub__(other))
753
- return self.__sub__(type(self)(other))
754
-
755
- @classmethod
756
- def check_items(cls, items: Iterable[THashable], /) -> None:
757
- _ = items
758
-
759
- def filter(self, func: Callable[[THashable], bool], /) -> Self:
760
- return type(self)(filter(func, self))
761
-
762
- def map(self, func: Callable[[THashable], THashable2], /) -> Collection[THashable2]:
763
- values = cast("Any", map(func, self))
764
- return cast("Any", type(self)(values))
765
-
766
- def partition(self, func: Callable[[THashable], bool], /) -> tuple[Self, Self]:
767
- from more_itertools import partition
768
-
769
- is_false, is_true = partition(func, self)
770
- return type(self)(is_false), type(self)(is_true)
771
-
772
-
773
- ##
774
-
775
-
776
724
  def ensure_hashables(
777
725
  *args: Any, **kwargs: Any
778
726
  ) -> tuple[list[Hashable], dict[str, Hashable]]:
utilities/libcst.py CHANGED
@@ -20,6 +20,8 @@ from libcst import (
20
20
  Name,
21
21
  )
22
22
 
23
+ from utilities.errors import ImpossibleCaseError
24
+
23
25
 
24
26
  def generate_from_import(
25
27
  module: str, name: str, /, *, asname: str | None = None
@@ -111,7 +113,7 @@ class _ParseImportAliasError(ParseImportError):
111
113
  @override
112
114
  def __str__(self) -> str:
113
115
  attr = self.attr
114
- return f"Invalid alias name; got module {self.module!r} and attribute '{attr.value.value}.{attr.attr.value}'"
116
+ return f"Invalid alias name; got module {self.module!r} and attribute '{attr.value}.{attr.attr}'"
115
117
 
116
118
 
117
119
  ##
@@ -138,23 +140,13 @@ def join_dotted_str(name_or_attr: Name | Attribute, /) -> str:
138
140
  case Attribute(value=value, attr=Name(value=attr_value)):
139
141
  parts.append(attr_value)
140
142
  curr = value
141
- case BaseExpression() as expr:
142
- raise JoinDottedStrError(name_or_attr=name_or_attr, expr=expr)
143
+ case BaseExpression(): # pragma: no cover
144
+ raise ImpossibleCaseError(case=[f"{curr=}"])
143
145
  case _ as never:
144
146
  assert_never(never)
145
147
  return ".".join(reversed(parts))
146
148
 
147
149
 
148
- @dataclass(kw_only=True, slots=True)
149
- class JoinDottedStrError(Exception):
150
- name_or_attr: Name | Attribute
151
- expr: BaseExpression
152
-
153
- @override
154
- def __str__(self) -> str:
155
- return f"Only names & attributes allowed; got {self.expr}"
156
-
157
-
158
150
  ##
159
151
 
160
152
 
@@ -13,7 +13,7 @@ if TYPE_CHECKING:
13
13
  from lightweight_charts import AbstractChart, Chart
14
14
  from lightweight_charts.abstract import SeriesCommon
15
15
  from polars import DataFrame
16
- from polars._typing import SchemaDict # pyright: ignore[reportPrivateImportUsage]
16
+ from polars._typing import SchemaDict
17
17
 
18
18
  from utilities.types import PathLike
19
19
 
utilities/polars.py CHANGED
@@ -112,14 +112,14 @@ if TYPE_CHECKING:
112
112
  from collections.abc import Set as AbstractSet
113
113
 
114
114
  from polars._typing import (
115
- IntoExpr, # pyright: ignore[reportPrivateImportUsage]
116
- IntoExprColumn, # pyright: ignore[reportPrivateImportUsage]
117
- JoinStrategy, # pyright: ignore[reportPrivateImportUsage]
118
- JoinValidation, # pyright: ignore[reportPrivateImportUsage]
119
- PolarsDataType, # pyright: ignore[reportPrivateImportUsage]
120
- QuantileMethod, # pyright: ignore[reportPrivateImportUsage]
121
- SchemaDict, # pyright: ignore[reportPrivateImportUsage]
122
- TimeUnit, # pyright: ignore[reportPrivateImportUsage]
115
+ IntoExpr,
116
+ IntoExprColumn,
117
+ JoinStrategy,
118
+ JoinValidation,
119
+ PolarsDataType,
120
+ QuantileMethod,
121
+ SchemaDict,
122
+ TimeUnit,
123
123
  )
124
124
 
125
125
  from utilities.numpy import NDArrayB, NDArrayF
utilities/polars_ols.py CHANGED
@@ -10,9 +10,7 @@ from utilities.functions import is_sequence_of
10
10
  from utilities.polars import concat_series, ensure_expr_or_series
11
11
 
12
12
  if TYPE_CHECKING:
13
- from polars._typing import (
14
- IntoExprColumn, # pyright: ignore[reportPrivateImportUsage]
15
- )
13
+ from polars._typing import IntoExprColumn
16
14
  from polars_ols import NullPolicy
17
15
 
18
16
  from utilities.polars import ExprLike
utilities/pyrsistent.py CHANGED
@@ -5,11 +5,11 @@ from typing import TYPE_CHECKING, Any, TypeVar, dataclass_transform, overload
5
5
  from pyrsistent import PRecord as _PRecord
6
6
  from pyrsistent import field as _field
7
7
  from pyrsistent._field_common import (
8
- PFIELD_NO_FACTORY, # pyright: ignore[reportPrivateImportUsage]
9
- PFIELD_NO_INITIAL, # pyright: ignore[reportPrivateImportUsage]
10
- PFIELD_NO_INVARIANT, # pyright: ignore[reportPrivateImportUsage]
11
- PFIELD_NO_SERIALIZER, # pyright: ignore[reportPrivateImportUsage]
12
- PFIELD_NO_TYPE, # pyright: ignore[reportPrivateImportUsage]
8
+ PFIELD_NO_FACTORY,
9
+ PFIELD_NO_INITIAL,
10
+ PFIELD_NO_INVARIANT,
11
+ PFIELD_NO_SERIALIZER,
12
+ PFIELD_NO_TYPE,
13
13
  )
14
14
 
15
15
  if TYPE_CHECKING:
utilities/pytest.py CHANGED
@@ -35,11 +35,9 @@ if TYPE_CHECKING:
35
35
  )
36
36
 
37
37
  try: # WARNING: this package cannot use unguarded `pytest` imports
38
- from _pytest.config import Config # pyright: ignore[reportPrivateImportUsage]
39
- from _pytest.config.argparsing import (
40
- Parser, # pyright: ignore[reportPrivateImportUsage]
41
- )
42
- from _pytest.python import Function # pyright: ignore[reportPrivateImportUsage]
38
+ from _pytest.config import Config
39
+ from _pytest.config.argparsing import Parser
40
+ from _pytest.python import Function
43
41
  from pytest import mark, skip
44
42
  except ModuleNotFoundError: # pragma: no cover
45
43
  from typing import Any as Config
@@ -60,10 +60,7 @@ if TYPE_CHECKING:
60
60
  Mapping,
61
61
  )
62
62
 
63
- from polars._typing import (
64
- PolarsDataType, # pyright: ignore[reportPrivateImportUsage]
65
- SchemaDict, # pyright: ignore[reportPrivateImportUsage]
66
- )
63
+ from polars._typing import PolarsDataType, SchemaDict
67
64
  from sqlalchemy.sql import ColumnCollection
68
65
  from sqlalchemy.sql.base import ReadOnlyColumnCollection
69
66
  from tenacity.retry import RetryBaseT