dycw-utilities 0.166.17__py3-none-any.whl → 0.166.18__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.166.17.dist-info → dycw_utilities-0.166.18.dist-info}/METADATA +1 -1
- {dycw_utilities-0.166.17.dist-info → dycw_utilities-0.166.18.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/pydantic_settings.py +85 -11
- {dycw_utilities-0.166.17.dist-info → dycw_utilities-0.166.18.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.166.17.dist-info → dycw_utilities-0.166.18.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.166.17.dist-info → dycw_utilities-0.166.18.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=eLNz3cP1mG4UANDG5gmXTTw10EMSDNNxdbNlerf7XNk,61
|
2
2
|
utilities/aeventkit.py,sha256=ddoleSwW9zdc2tjX5Ge0pMKtYwV_JMxhHYOxnWX2AGM,12609
|
3
3
|
utilities/altair.py,sha256=nHdpWt8ZwdUwRQN970MvHd5bRWokNqzHcZQEdSHKRuE,9033
|
4
4
|
utilities/asyncio.py,sha256=PUedzQ5deqlSECQ33sam9cRzI9TnygHz3FdOqWJWPTM,15288
|
@@ -53,7 +53,7 @@ utilities/pottery.py,sha256=ggMN72Y7wx7Js8VN6eyNyodpm8TIYqZHGghkDPXIVWk,3949
|
|
53
53
|
utilities/pqdm.py,sha256=idv2seRVP2f6NeSfpeEnT5A-tQezaHZKDyeu16g2-0E,3091
|
54
54
|
utilities/psutil.py,sha256=KUlu4lrUw9Zg1V7ZGetpWpGb9DB8l_SSDWGbANFNCPU,2104
|
55
55
|
utilities/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
56
|
-
utilities/pydantic_settings.py,sha256=
|
56
|
+
utilities/pydantic_settings.py,sha256=CWrTtzupGxpSsImjDCuVtQ2HcGmF8nHA4W4hGq8WvXY,5688
|
57
57
|
utilities/pydantic_settings_sops.py,sha256=LWI3NTQP8hSaGkoRbahyqaalF0HuBg7o63-p7boHgpQ,1119
|
58
58
|
utilities/pyinstrument.py,sha256=hnXaL-4HE7wWBI5JKaPfYTpsrXe68YiuZKahHV0VJn8,841
|
59
59
|
utilities/pytest.py,sha256=Pu8jmeNQq659uQmZsmFj6lb0sHMDsNN3fcd6M21J-ww,7723
|
@@ -91,8 +91,8 @@ utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
|
|
91
91
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
92
92
|
utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
|
93
93
|
utilities/pytest_plugins/pytest_regressions.py,sha256=9v8kAXDM2ycIXJBimoiF4EgrwbUvxTycFWJiGR_GHhM,1466
|
94
|
-
dycw_utilities-0.166.
|
95
|
-
dycw_utilities-0.166.
|
96
|
-
dycw_utilities-0.166.
|
97
|
-
dycw_utilities-0.166.
|
98
|
-
dycw_utilities-0.166.
|
94
|
+
dycw_utilities-0.166.18.dist-info/METADATA,sha256=NPBYGvJB7ozKQT3NMI0xHlTtFcCcchzIBb5YmxnoptU,1702
|
95
|
+
dycw_utilities-0.166.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
96
|
+
dycw_utilities-0.166.18.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
97
|
+
dycw_utilities-0.166.18.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
98
|
+
dycw_utilities-0.166.18.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/pydantic_settings.py
CHANGED
@@ -31,9 +31,9 @@ class CustomBaseSettings(BaseSettings):
|
|
31
31
|
"""Base settings for loading JSON files."""
|
32
32
|
|
33
33
|
# paths
|
34
|
-
json_files: ClassVar[Sequence[
|
34
|
+
json_files: ClassVar[Sequence[PathLikeOrWithSection]] = []
|
35
35
|
toml_files: ClassVar[Sequence[PathLikeOrWithSection]] = []
|
36
|
-
yaml_files: ClassVar[Sequence[
|
36
|
+
yaml_files: ClassVar[Sequence[PathLikeOrWithSection]] = []
|
37
37
|
|
38
38
|
# config
|
39
39
|
model_config: ClassVar[SettingsConfigDict] = SettingsConfigDict(
|
@@ -61,20 +61,36 @@ class CustomBaseSettings(BaseSettings):
|
|
61
61
|
/,
|
62
62
|
) -> Iterator[PydanticBaseSettingsSource]:
|
63
63
|
yield env_settings
|
64
|
-
for
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
case Path() | str() as file:
|
69
|
-
yield
|
64
|
+
for json in cls.json_files:
|
65
|
+
match json:
|
66
|
+
case Path() | str():
|
67
|
+
yield JsonConfigSettingsSource(settings_cls, json_file=json)
|
68
|
+
case Path() | str() as file, str() | list() | tuple() as section:
|
69
|
+
yield JsonConfigSectionSettingsSource(
|
70
|
+
settings_cls, json_file=file, section=section
|
71
|
+
)
|
72
|
+
case never:
|
73
|
+
assert_never(never)
|
74
|
+
for toml in cls.toml_files:
|
75
|
+
match toml:
|
76
|
+
case Path() | str():
|
77
|
+
yield TomlConfigSettingsSource(settings_cls, toml_file=toml)
|
70
78
|
case Path() | str() as file, str() | list() | tuple() as section:
|
71
79
|
yield TomlConfigSectionSettingsSource(
|
72
80
|
settings_cls, toml_file=file, section=section
|
73
81
|
)
|
74
82
|
case never:
|
75
83
|
assert_never(never)
|
76
|
-
for
|
77
|
-
|
84
|
+
for yaml in cls.yaml_files:
|
85
|
+
match yaml:
|
86
|
+
case Path() | str():
|
87
|
+
yield YamlConfigSettingsSource(settings_cls, yaml_file=yaml)
|
88
|
+
case Path() | str() as file, str() | list() | tuple() as section:
|
89
|
+
yield YamlConfigSectionSettingsSource(
|
90
|
+
settings_cls, yaml_file=file, section=section
|
91
|
+
)
|
92
|
+
case never:
|
93
|
+
assert_never(never)
|
78
94
|
|
79
95
|
|
80
96
|
def load_settings[T: BaseSettings](cls: type[T], /) -> T:
|
@@ -82,6 +98,30 @@ def load_settings[T: BaseSettings](cls: type[T], /) -> T:
|
|
82
98
|
return cls()
|
83
99
|
|
84
100
|
|
101
|
+
class JsonConfigSectionSettingsSource(JsonConfigSettingsSource):
|
102
|
+
@override
|
103
|
+
def __init__(
|
104
|
+
self,
|
105
|
+
settings_cls: type[BaseSettings],
|
106
|
+
json_file: PathType | None = DEFAULT_PATH,
|
107
|
+
json_file_encoding: str | None = None,
|
108
|
+
*,
|
109
|
+
section: MaybeSequenceStr,
|
110
|
+
) -> None:
|
111
|
+
super().__init__(
|
112
|
+
settings_cls, json_file=json_file, json_file_encoding=json_file_encoding
|
113
|
+
)
|
114
|
+
self.section = section
|
115
|
+
|
116
|
+
@override
|
117
|
+
def __call__(self) -> dict[str, Any]:
|
118
|
+
return reduce(
|
119
|
+
lambda acc, el: acc.get(el, {}),
|
120
|
+
always_iterable(self.section),
|
121
|
+
super().__call__(),
|
122
|
+
)
|
123
|
+
|
124
|
+
|
85
125
|
class TomlConfigSectionSettingsSource(TomlConfigSettingsSource):
|
86
126
|
@override
|
87
127
|
def __init__(
|
@@ -103,4 +143,38 @@ class TomlConfigSectionSettingsSource(TomlConfigSettingsSource):
|
|
103
143
|
)
|
104
144
|
|
105
145
|
|
106
|
-
|
146
|
+
class YamlConfigSectionSettingsSource(YamlConfigSettingsSource):
|
147
|
+
@override
|
148
|
+
def __init__(
|
149
|
+
self,
|
150
|
+
settings_cls: type[BaseSettings],
|
151
|
+
yaml_file: PathType | None = DEFAULT_PATH,
|
152
|
+
yaml_file_encoding: str | None = None,
|
153
|
+
yaml_config_section: str | None = None,
|
154
|
+
*,
|
155
|
+
section: MaybeSequenceStr,
|
156
|
+
) -> None:
|
157
|
+
super().__init__(
|
158
|
+
settings_cls,
|
159
|
+
yaml_file=yaml_file,
|
160
|
+
yaml_file_encoding=yaml_file_encoding,
|
161
|
+
yaml_config_section=yaml_config_section,
|
162
|
+
)
|
163
|
+
self.section = section
|
164
|
+
|
165
|
+
@override
|
166
|
+
def __call__(self) -> dict[str, Any]:
|
167
|
+
return reduce(
|
168
|
+
lambda acc, el: acc.get(el, {}),
|
169
|
+
always_iterable(self.section),
|
170
|
+
super().__call__(),
|
171
|
+
)
|
172
|
+
|
173
|
+
|
174
|
+
__all__ = [
|
175
|
+
"CustomBaseSettings",
|
176
|
+
"JsonConfigSectionSettingsSource",
|
177
|
+
"TomlConfigSectionSettingsSource",
|
178
|
+
"YamlConfigSectionSettingsSource",
|
179
|
+
"load_settings",
|
180
|
+
]
|
File without changes
|
File without changes
|
File without changes
|