Debian Codegraph @

debian/patches/dgit-changes

raw
1 From:
2 Subject: Debian changes
3
4 The Debian packaging of pyecotrend-ista is maintained in git, using a workflow
5 similar to the one described in dgit-maint-merge(7).
6 The Debian delta is represented by this one combined patch; there isn't a
7 patch queue that can be represented as a quilt series.
8
9 A detailed breakdown of the changes is available from their canonical
10 representation -- git commits in the packaging repository.
11 For example, to see the changes made by the Debian maintainer in the first
12 upload of upstream version 1.2.3, you could use:
13
14 % git clone https://git.dgit.debian.org/pyecotrend-ista
15 % cd pyecotrend-ista
16 % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'
17
18 (If you have dgit, use `dgit clone pyecotrend-ista`, rather than plain `git clone`.)
19
20 We don't use debian/source/options single-debian-patch because it has bugs.
21 Therefore, NMUs etc. may nevertheless have made additional patches.
22
23 ---
24
25 diff --git a/pyproject.toml b/pyproject.toml
26 index 88e1616..9339858 100644
27 --- a/pyproject.toml
28 +++ b/pyproject.toml
29 @@ -1,6 +1,6 @@
30 [build-system]
31 build-backend = "setuptools.build_meta"
32 -requires = ['setuptools>=77.0.3', "setuptools-scm", "requests", "dataclasses-json"]
33 +requires = ['setuptools>=77.0.3', "setuptools-scm", "requests"]
34
35 [project]
36 authors = [
37 @@ -22,8 +22,7 @@ classifiers = [
38 "Topic :: Software Development :: Libraries :: Python Modules"
39 ]
40 dependencies = [
41 - "requests>=2",
42 - "dataclasses-json>=0.6"
43 + "requests>=2"
44 ]
45 description = "Python EcoTrend-ista Api"
46 dynamic = ["version", "readme"]
47 diff --git a/requirements.in b/requirements.in
48 index 508a4ab..d539cf2 100644
49 --- a/requirements.in
50 +++ b/requirements.in
51 @@ -1,6 +1,5 @@
52 # Main dependencies
53 requests>=2
54 -dataclasses-json>=0.6
55
56 # Optional dependencies: doc
57 babel==2.17.0
58 diff --git a/requirements.txt b/requirements.txt
59 index 0fa43e0..a1060ec 100644
60 --- a/requirements.txt
61 +++ b/requirements.txt
62 @@ -262,10 +262,6 @@ csscompressor==0.9.5 \
63 # via
64 # -r requirements.in
65 # mkdocs-minify-plugin
66 -dataclasses-json==0.6.7 \
67 - --hash=sha256:0dbf33f26c8d5305befd61b39d2b3414e8a407bedc2834dea9b8d642666fb40a \
68 - --hash=sha256:b6b3e528266ea45b9535223bc53ca645f5208833c29229e847b3f26a1cc55fc0
69 - # via -r requirements.in
70 distlib==0.4.0 \
71 --hash=sha256:9659f7d87e46584a30b5780e43ac7a2143098441670ff0a49d5f9034c54a6c16 \
72 --hash=sha256:feec40075be03a04501a973d81f633735b4b69f98b05450592310c0f401a4e0d
73 @@ -443,10 +439,6 @@ markupsafe==3.0.3 \
74 # mkdocs
75 # mkdocs-autorefs
76 # mkdocstrings
77 -marshmallow==3.26.1 \
78 - --hash=sha256:3350409f20a70a7e4e11a27661187b77cdcaeb20abca41c1454fe33636bea09c \
79 - --hash=sha256:e6d8affb6cb61d39d26402096dc0aee12d5a26d490a121f118d2e81dc0719dc6
80 - # via dataclasses-json
81 mdx-gh-links==0.4 \
82 --hash=sha256:41d5aac2ab201425aa0a19373c4095b79e5e015fdacfe83c398199fe55ca3686 \
83 --hash=sha256:9057bca1fa5280bf1fcbf354381e46c9261cc32c2d5c0407801f8a910be5f099
84 @@ -840,10 +832,6 @@ typing-extensions==4.15.0 \
85 --hash=sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466 \
86 --hash=sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548
87 # via typing-inspect
88 -typing-inspect==0.9.0 \
89 - --hash=sha256:9ee6fc59062311ef8547596ab6b955e1b8aa46242d854bfc78f4f6b0eff35f9f \
90 - --hash=sha256:b23fc42ff6f6ef6954e4852c1fb512cdd18dbea03134f91f856a95ccc9461f78
91 - # via dataclasses-json
92 urllib3==2.6.1 \
93 --hash=sha256:5379eb6e1aba4088bae84f8242960017ec8d8e3decf30480b3a1abdaa9671a3f \
94 --hash=sha256:e67d06fe947c36a7ca39f4994b08d73922d40e6cca949907be05efa6fd75110b
95 diff --git a/src/pyecotrend_ista/helper_object_de.py b/src/pyecotrend_ista/helper_object_de.py
96 index 484fd3e..31b2d75 100644
97 --- a/src/pyecotrend_ista/helper_object_de.py
98 +++ b/src/pyecotrend_ista/helper_object_de.py
99 @@ -2,15 +2,83 @@
100
101 from __future__ import annotations
102
103 -from dataclasses import dataclass
104 +from dataclasses import MISSING, asdict, dataclass, fields, is_dataclass
105 +import json
106 +from types import NoneType, UnionType
107 +from typing import Any, TypeVar, get_args, get_origin, get_type_hints
108
109 -from dataclasses_json import DataClassJsonMixin, dataclass_json
110 +T = TypeVar("T", bound="DataClassDictMixin")
111 +
112 +
113 +def _decode_value(value: Any, annotation: Any) -> Any:
114 + """Decode a plain Python value into the target annotation."""
115 + if annotation is Any:
116 + return value
117 +
118 + origin = get_origin(annotation)
119 + args = get_args(annotation)
120 +
121 + if origin in (list, tuple):
122 + inner_type = args[0] if args else Any
123 + return [_decode_value(item, inner_type) for item in value]
124 +
125 + if origin is dict:
126 + key_type, value_type = args if args else (Any, Any)
127 + return {_decode_value(key, key_type): _decode_value(item, value_type) for key, item in value.items()}
128 +
129 + if origin in (UnionType,):
130 + non_none_args = [arg for arg in args if arg is not NoneType]
131 + if value is None and len(non_none_args) != len(args):
132 + return None
133 + for arg in non_none_args:
134 + try:
135 + return _decode_value(value, arg)
136 + except (TypeError, ValueError, AttributeError):
137 + continue
138 + return value
139 +
140 + if is_dataclass(annotation):
141 + return annotation.from_dict(value)
142 +
143 + if annotation is NoneType or value is None:
144 + return None
145 +
146 + return value
147 +
148 +
149 +class DataClassDictMixin:
150 + """Minimal dataclass dict/json conversion helpers."""
151 +
152 + @classmethod
153 + def from_dict(cls: type[T], value: dict[str, Any] | None) -> T:
154 + """Build a dataclass instance from a nested dictionary."""
155 + if value is None:
156 + raise TypeError(f"Cannot build {cls.__name__} from None")
157 +
158 + type_hints = get_type_hints(cls)
159 + kwargs = {}
160 + for field in fields(cls):
161 + if field.name in value:
162 + kwargs[field.name] = _decode_value(value[field.name], type_hints.get(field.name, field.type))
163 + elif field.default is not MISSING or field.default_factory is not MISSING:
164 + continue
165 + else:
166 + raise TypeError(f"Missing required field '{field.name}' for {cls.__name__}")
167 + return cls(**kwargs)
168 +
169 + @classmethod
170 + def from_json(cls: type[T], value: str) -> T:
171 + """Build a dataclass instance from a JSON document."""
172 + return cls.from_dict(json.loads(value))
173 +
174 + def to_dict(self) -> dict[str, Any]:
175 + """Convert a dataclass instance into a nested dictionary."""
176 + return asdict(self)
177
178
179 # pylint: disable=invalid-name
180 -@dataclass_json
181 @dataclass
182 -class AverageConsumption(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
183 +class AverageConsumption(DataClassDictMixin): # numpydoc ignore=ES01,EX01
184 """Represents average consumption data.
185
186 Attributes
187 @@ -60,9 +128,8 @@ class AverageConsumption(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
188 self.replace_point()
189
190
191 -@dataclass_json
192 @dataclass
193 -class ComparedConsumption(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
194 +class ComparedConsumption(DataClassDictMixin): # numpydoc ignore=ES01,EX01
195 """
196 Represents compared consumption data.
197
198 @@ -101,9 +168,8 @@ class ComparedConsumption(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
199 self.replace_point()
200
201
202 -@dataclass_json
203 @dataclass
204 -class Consumption(DataClassJsonMixin): # numpydoc ignore=ES01,EX01,PR02
205 +class Consumption(DataClassDictMixin): # numpydoc ignore=ES01,EX01,PR02
206 """Data class representing consumption.
207
208 Parameters
209 @@ -151,9 +217,8 @@ class Consumption(DataClassJsonMixin): # numpydoc ignore=ES01,EX01,PR02
210 self.replace_point()
211
212
213 -@dataclass_json
214 @dataclass
215 -class Cost(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
216 +class Cost(DataClassDictMixin): # numpydoc ignore=ES01,EX01
217 """Data class representing cost information.
218
219 Attributes
220 @@ -177,9 +242,8 @@ class Cost(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
221 comparedCost: ComparedConsumption | None # noqa: N815
222
223
224 -@dataclass_json
225 @dataclass
226 -class Date(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
227 +class Date(DataClassDictMixin): # numpydoc ignore=ES01,EX01
228 """Data class representing a date with month and year.
229
230 Attributes
231 @@ -194,9 +258,8 @@ class Date(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
232 year: int
233
234
235 -@dataclass_json
236 @dataclass
237 -class LastValue(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
238 +class LastValue(DataClassDictMixin): # numpydoc ignore=ES01,EX01
239 """Data class representing last values.
240
241 Attributes
242 @@ -229,9 +292,8 @@ class LastValue(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
243 h: str | None = None
244
245
246 -@dataclass_json
247 @dataclass
248 -class LastCustomValue(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
249 +class LastCustomValue(DataClassDictMixin): # numpydoc ignore=ES01,EX01
250 """Data class representing last custom values.
251
252 Attributes
253 @@ -264,9 +326,8 @@ class LastCustomValue(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
254 h: str | None = None
255
256
257 -@dataclass_json
258 @dataclass
259 -class LastCosts(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
260 +class LastCosts(DataClassDictMixin): # numpydoc ignore=ES01,EX01
261 """Data class representing last costs.
262
263 Attributes
264 @@ -293,9 +354,8 @@ class LastCosts(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
265 unit: str | None = None
266
267
268 -@dataclass_json
269 @dataclass
270 -class CombinedData(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
271 +class CombinedData(DataClassDictMixin): # numpydoc ignore=ES01,EX01
272 """Data class representing combined data.
273
274 Attributes
275 @@ -313,9 +373,8 @@ class CombinedData(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
276 costs: list[Cost]
277
278
279 -@dataclass_json
280 @dataclass
281 -class TotalAdditionalValues(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
282 +class TotalAdditionalValues(DataClassDictMixin): # numpydoc ignore=ES01,EX01
283 """Data class for representing total additional values.
284
285 Attributes
286 @@ -342,9 +401,8 @@ class TotalAdditionalValues(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
287 h: str | None = None
288
289
290 -@dataclass_json
291 @dataclass
292 -class TotalAdditionalCustomValues(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
293 +class TotalAdditionalCustomValues(DataClassDictMixin): # numpydoc ignore=ES01,EX01
294 """Data class for representing total additional custom values.
295
296 Attributes
297 @@ -371,9 +429,8 @@ class TotalAdditionalCustomValues(DataClassJsonMixin): # numpydoc ignore=ES01,E
298 h: str | None = None
299
300
301 -@dataclass_json
302 @dataclass
303 -class SumByYear(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
304 +class SumByYear(DataClassDictMixin): # numpydoc ignore=ES01,EX01
305 """Data class for representing the sum of values grouped by year.
306
307 Attributes
308 @@ -400,9 +457,8 @@ class SumByYear(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
309 h: str | None = None
310
311
312 -@dataclass_json
313 @dataclass
314 -class CustomRaw(DataClassJsonMixin): # numpydoc ignore=ES01,EX01
315 +class CustomRaw(DataClassDictMixin): # numpydoc ignore=ES01,EX01
316 """Data class for representing custom raw data.
317
318 Attributes