pydiagral 1.5.1__py3-none-any.whl → 1.5.2__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.
pydiagral/models.py CHANGED
@@ -13,7 +13,7 @@ from datetime import datetime, timezone
13
13
  import logging
14
14
  import re
15
15
  import types
16
- from typing import TypeVar, Union, get_args, get_origin, get_type_hints
16
+ from typing import Self, Union, get_args, get_origin, get_type_hints
17
17
 
18
18
  logger: logging.Logger = logging.getLogger(__name__)
19
19
 
@@ -54,9 +54,6 @@ class CamelCaseModel:
54
54
 
55
55
  """
56
56
 
57
- # Type variable for the class itself
58
- T = TypeVar("T", bound="CamelCaseModel")
59
-
60
57
  def to_dict(self) -> dict:
61
58
  """Convert the instance attributes to a dictionary, transforming attribute names.
62
59
 
@@ -90,7 +87,7 @@ class CamelCaseModel:
90
87
  return result
91
88
 
92
89
  @classmethod
93
- def _from_dict_recursive(cls: type[T], data: dict, target_cls: type[T]) -> T:
90
+ def _from_dict_recursive(cls, data: dict, target_cls: type[Self]) -> Self:
94
91
  """Recursively converts a dictionary to an instance of the specified target class.
95
92
 
96
93
  This method handles nested dictionaries and lists, converting them to the appropriate
@@ -98,12 +95,12 @@ class CamelCaseModel:
98
95
  by handling `Union` types and removing `None` from the type hints.
99
96
 
100
97
  Args:
101
- cls (type[T]): The class that this method is a part of.
98
+ cls (type[Self]): The class that this method is a part of.
102
99
  data (dict): The dictionary to convert.
103
- target_cls (type[T]): The target class to convert the dictionary to.
100
+ target_cls (type[Self]): The target class to convert the dictionary to.
104
101
 
105
102
  Returns:
106
- T: An instance of the target class populated with the data from the dictionary.
103
+ An instance of the target class populated with the data from the dictionary.
107
104
 
108
105
  Raises:
109
106
  TypeError: If the target class cannot be instantiated with the provided data.
@@ -187,15 +184,15 @@ class CamelCaseModel:
187
184
  return target_cls(**init_values)
188
185
 
189
186
  @classmethod
190
- def from_dict(cls: type[T], data: dict) -> T:
187
+ def from_dict(cls, data: dict) -> Self:
191
188
  """Create an instance of the class from a dictionary.
192
189
 
193
190
  Args:
194
- cls (type[T]): The class type to instantiate.
191
+ cls (type[Self]): The class type to instantiate.
195
192
  data (dict): The dictionary containing the data to populate the instance.
196
193
 
197
194
  Returns:
198
- T: An instance of the class populated with the data from the dictionary.
195
+ An instance of the class populated with the data from the dictionary.
199
196
 
200
197
  Example:
201
198
  >>> data = {"diagral_id": 123, "user_id": 456, "access_token": "abc123"}
@@ -830,11 +827,11 @@ class AlarmConfiguration(CamelCaseModel):
830
827
  reading_date (datetime | None): The date when the configuration was read, aliased as "readingDate".
831
828
  transceivers (list[TransceiverModel] | None): A list of transceiver models.
832
829
  transmitters (list[TransmitterModel] | None): A list of transmitter models.
833
- grp_marche_presence (list[int] | None): A list of group marche presence, aliased as "grpMarchePresence".
830
+ presence_group (list[int] | None): A list of group marche presence, aliased as "presenceGroup".
834
831
  installation_state (int | None): The state of the installation, aliased as "installationState".
835
832
  central_information (CentralInformation | None): Information about the central unit, aliased as "centralInformation".
836
- grp_marche_partielle1 (list[int] | None): A list of group marche partielle 1, aliased as "grpMarchePartielle1".
837
- grp_marche_partielle2 (list[int] | None): A list of group marche partielle 2, aliased as "grpMarchePartielle2".
833
+ partial_group1 (list[int] | None): A list of group marche partielle 1, aliased as "partialGroup1".
834
+ partial_group2 (list[int] | None): A list of group marche partielle 2, aliased as "partialGroup2".
838
835
 
839
836
  Example:
840
837
  >>> alarm_config = AlarmConfiguration(
@@ -847,11 +844,11 @@ class AlarmConfiguration(CamelCaseModel):
847
844
  ... reading_date=datetime(2023, 10, 1),
848
845
  ... transceivers=[TransceiverModel(uid="11223", type=5)],
849
846
  ... transmitters=[TransmitterModel(uid="44556", type=6)],
850
- ... grp_marche_presence=[1, 2, 3],
847
+ ... presence_group=[1, 2, 3],
851
848
  ... installation_state=1,
852
849
  ... central_information=CentralInformation(has_plug=True),
853
- ... grp_marche_partielle1=[4, 5, 6],
854
- ... grp_marche_partielle2=[7, 8, 9]
850
+ ... partial_group1=[4, 5, 6],
851
+ ... partial_group2=[7, 8, 9]
855
852
  ... )
856
853
  >>> print(alarm_config.alarm.name)
857
854
  Home Alarm
@@ -870,8 +867,8 @@ class AlarmConfiguration(CamelCaseModel):
870
867
  )
871
868
  transceivers: list[TransceiverModel] | None = None
872
869
  transmitters: list[TransmitterModel] | None = None
873
- grp_marche_presence: list[int] | None = field(
874
- default=None, metadata={"alias": "grpMarchePresence"}
870
+ presence_group: list[int] | None = field(
871
+ default=None, metadata={"alias": "presenceGroup"}
875
872
  )
876
873
  installation_state: int | None = field(
877
874
  default=None, metadata={"alias": "installationState"}
@@ -879,11 +876,11 @@ class AlarmConfiguration(CamelCaseModel):
879
876
  central_information: CentralInformation | None = field(
880
877
  default=None, metadata={"alias": "centralInformation"}
881
878
  )
882
- grp_marche_partielle1: list[int] | None = field(
883
- default=None, metadata={"alias": "grpMarchePartielle1"}
879
+ partial_group1: list[int] | None = field(
880
+ default=None, metadata={"alias": "partialGroup1"}
884
881
  )
885
- grp_marche_partielle2: list[int] | None = field(
886
- default=None, metadata={"alias": "grpMarchePartielle2"}
882
+ partial_group2: list[int] | None = field(
883
+ default=None, metadata={"alias": "partialGroup2"}
887
884
  )
888
885
 
889
886
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydiagral
3
- Version: 1.5.1
3
+ Version: 1.5.2
4
4
  Summary: A Python library for interacting with Diagral systems
5
5
  Project-URL: Homepage, https://github.com/mguyard/pydiagral
6
6
  Project-URL: Documentation, https://github.com/mguyard/pydiagral
@@ -2,9 +2,9 @@ pydiagral/__init__.py,sha256=4uM-RD2GQ6JYJkxu-D6wj3XpqfY5gN2hP8NF6WvRI9k,576
2
2
  pydiagral/api.py,sha256=nEmP1UuZWIMoSpWMxGk4dF2AbejlE7AJHMTBGUeLra8,50129
3
3
  pydiagral/constants.py,sha256=2B0TdKxQHA3cpIBxojo43bMW44wN9xKYsHbBRHWsaBk,119
4
4
  pydiagral/exceptions.py,sha256=vMhGDQW-AhYIH9gcKHK1-4SHV3eZUXeeqXPyznUAKnU,1211
5
- pydiagral/models.py,sha256=lXsVoyy3WAkBmk9V2jeFQM_CAQXcuZsyOZatlwze2kE,55161
5
+ pydiagral/models.py,sha256=c9tqZUUEhnjuqRhp5md-iKnQMHk8UsuP3TmH2qFKlPc,54976
6
6
  pydiagral/utils.py,sha256=-VxI-lNaC4bU1K4DSmWDhvbsS2bXv5FAGULGKBf1UMU,449
7
- pydiagral-1.5.1.dist-info/METADATA,sha256=dh2tCo5noHV47U6xTSfcXHo9NUWjk-zRqR8Dp77Q2Nk,48529
8
- pydiagral-1.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- pydiagral-1.5.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
10
- pydiagral-1.5.1.dist-info/RECORD,,
7
+ pydiagral-1.5.2.dist-info/METADATA,sha256=I4FzNyd2r-7cXZXimW1ccCzEg9EulaSLmFghdjQfapY,48529
8
+ pydiagral-1.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ pydiagral-1.5.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
10
+ pydiagral-1.5.2.dist-info/RECORD,,