s2-python 0.0.1__py3-none-any.whl → 0.1.3__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.
Files changed (50) hide show
  1. {s2_python-0.0.1.dist-info → s2_python-0.1.3.dist-info}/METADATA +37 -20
  2. s2_python-0.1.3.dist-info/RECORD +51 -0
  3. {s2_python-0.0.1.dist-info → s2_python-0.1.3.dist-info}/WHEEL +1 -1
  4. s2python/__init__.py +1 -1
  5. s2python/common/__init__.py +17 -16
  6. s2python/common/duration.py +3 -6
  7. s2python/common/handshake.py +6 -7
  8. s2python/common/handshake_response.py +6 -7
  9. s2python/common/instruction_status_update.py +8 -10
  10. s2python/common/number_range.py +10 -10
  11. s2python/common/power_forecast.py +7 -9
  12. s2python/common/power_forecast_element.py +4 -8
  13. s2python/common/power_forecast_value.py +2 -7
  14. s2python/common/power_measurement.py +7 -9
  15. s2python/common/power_range.py +6 -6
  16. s2python/common/power_value.py +2 -5
  17. s2python/common/reception_status.py +6 -9
  18. s2python/common/resource_manager_details.py +11 -10
  19. s2python/common/revoke_object.py +6 -8
  20. s2python/common/role.py +2 -5
  21. s2python/common/select_control_type.py +6 -7
  22. s2python/common/session_request.py +6 -7
  23. s2python/common/support.py +7 -5
  24. s2python/common/timer.py +2 -8
  25. s2python/common/transition.py +4 -15
  26. s2python/frbc/__init__.py +7 -7
  27. s2python/frbc/frbc_actuator_description.py +13 -13
  28. s2python/frbc/frbc_actuator_status.py +6 -17
  29. s2python/frbc/frbc_fill_level_target_profile.py +11 -11
  30. s2python/frbc/frbc_fill_level_target_profile_element.py +2 -6
  31. s2python/frbc/frbc_instruction.py +6 -10
  32. s2python/frbc/frbc_leakage_behaviour.py +9 -11
  33. s2python/frbc/frbc_leakage_behaviour_element.py +2 -5
  34. s2python/frbc/frbc_operation_mode.py +5 -9
  35. s2python/frbc/frbc_operation_mode_element.py +3 -6
  36. s2python/frbc/frbc_storage_description.py +2 -5
  37. s2python/frbc/frbc_storage_status.py +6 -7
  38. s2python/frbc/frbc_system_description.py +10 -9
  39. s2python/frbc/frbc_timer_status.py +6 -9
  40. s2python/frbc/frbc_usage_forecast.py +7 -9
  41. s2python/frbc/frbc_usage_forecast_element.py +2 -6
  42. s2python/generated/gen_s2.py +848 -833
  43. s2python/message.py +47 -0
  44. s2python/s2_parser.py +112 -0
  45. s2python/s2_validation_error.py +3 -1
  46. s2python/utils.py +7 -2
  47. s2python/validate_values_mixin.py +43 -25
  48. s2_python-0.0.1.dist-info/RECORD +0 -49
  49. {s2_python-0.0.1.dist-info → s2_python-0.1.3.dist-info}/entry_points.txt +0 -0
  50. {s2_python-0.0.1.dist-info → s2_python-0.1.3.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: s2-python
3
- Version: 0.0.1
3
+ Version: 0.1.3
4
4
  Summary: S2 Protocol Python Wrapper
5
5
  Home-page: https://github.com/flexiblepower/s2-ws-json-python
6
6
  Author: Flexiblepower
@@ -12,34 +12,36 @@ Classifier: Programming Language :: Python :: 3.8
12
12
  Classifier: Programming Language :: Python :: 3.9
13
13
  Classifier: Programming Language :: Python :: 3.10
14
14
  Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
15
16
  Description-Content-Type: text/x-rst; charset=UTF-8
16
- Requires-Dist: pydantic <=1.10.7
17
+ Requires-Dist: pydantic~=1.10.7
17
18
  Requires-Dist: pytz
18
19
  Requires-Dist: click
20
+ Provides-Extra: testing
21
+ Requires-Dist: pytest; extra == "testing"
22
+ Requires-Dist: pytest-coverage; extra == "testing"
23
+ Requires-Dist: pytest-timer; extra == "testing"
24
+ Requires-Dist: mypy; extra == "testing"
25
+ Requires-Dist: types-pytz; extra == "testing"
26
+ Requires-Dist: pylint; extra == "testing"
19
27
  Provides-Extra: development
20
- Requires-Dist: pip-tools ; extra == 'development'
21
- Requires-Dist: datamodel-code-generator ; extra == 'development'
22
- Requires-Dist: pre-commit ; extra == 'development'
23
- Requires-Dist: tox ; extra == 'development'
28
+ Requires-Dist: pip-tools; extra == "development"
29
+ Requires-Dist: datamodel-code-generator; extra == "development"
30
+ Requires-Dist: pre-commit; extra == "development"
31
+ Requires-Dist: tox; extra == "development"
24
32
  Provides-Extra: docs
25
- Requires-Dist: sphinx ; extra == 'docs'
26
- Requires-Dist: sphinx-rtd-theme >=1.2 ; extra == 'docs'
27
- Requires-Dist: sphinx-tabs ; extra == 'docs'
28
- Requires-Dist: sphinx-copybutton ; extra == 'docs'
29
- Requires-Dist: sphinx-fontawesome ; extra == 'docs'
30
- Requires-Dist: sphinxcontrib.httpdomain ; extra == 'docs'
31
- Provides-Extra: testing
32
- Requires-Dist: pytest ; extra == 'testing'
33
- Requires-Dist: pytest-coverage ; extra == 'testing'
34
- Requires-Dist: pytest-timer ; extra == 'testing'
35
- Requires-Dist: mypy ; extra == 'testing'
36
- Requires-Dist: pylint ; extra == 'testing'
33
+ Requires-Dist: sphinx; extra == "docs"
34
+ Requires-Dist: sphinx-rtd-theme>=1.2; extra == "docs"
35
+ Requires-Dist: sphinx-tabs; extra == "docs"
36
+ Requires-Dist: sphinx_copybutton; extra == "docs"
37
+ Requires-Dist: sphinx_fontawesome; extra == "docs"
38
+ Requires-Dist: sphinxcontrib.httpdomain; extra == "docs"
37
39
 
38
40
  Python Wrapper for S2 Flexibility Protocol
39
41
  ===========================================
40
42
  .. image:: https://img.shields.io/pypi/v/s2-python
41
43
  :alt: PyPI - Version
42
- .. image:: https://img.shields.io/pypi/pyversions/v/s2-python
44
+ .. image:: https://img.shields.io/pypi/pyversions/s2-python
43
45
  :alt: PyPI - Python Version
44
46
  .. image:: https://img.shields.io/pypi/l/s2-python
45
47
  :alt: PyPI - License
@@ -49,14 +51,29 @@ is based on the asyncapi description of the protocol provided in the `s2-ws-json
49
51
 
50
52
  Currently, the package supports the *common* and *FILL RATE BASED CONTROL* types and messages.
51
53
 
54
+ To Install
55
+ -----------
56
+ You can install this package using pip or any Python dependency manager that collects the packages from Pypi:
57
+
58
+ .. code-block:: bash
59
+
60
+ pip install s2-python
61
+
62
+ The packages on Pypi may be found `here <https://pypi.org/project/s2-python/>`_
52
63
 
53
64
  Example
54
65
  ---------
55
66
 
56
67
  .. code-block:: python
57
68
 
69
+ from s2python.common import PowerRange, CommodityQuantity
70
+
58
71
  # create s2 messages as Python objects
59
- number_range = PowerRange(start_of_range=4.0, end_of_range=5.0, commodity_quantity=CommodityQuantity.ELECTRIC_POWER_L1)
72
+ number_range = PowerRange(
73
+ start_of_range=4.0,
74
+ end_of_range=5.0,
75
+ commodity_quantity=CommodityQuantity.ELECTRIC_POWER_L1,
76
+ )
60
77
  # serialize s2 messages
61
78
  number_range.to_json()
62
79
  # deserialize s2 messages
@@ -0,0 +1,51 @@
1
+ s2python/__init__.py,sha256=e5lwvqsPl-z7IfEd0hRQhLBRKBYcuw2eqrecXnMfLdg,384
2
+ s2python/message.py,sha256=BeKrzLQRkBYkJseo4O9vrMgKwG2YBLRIMNHllPcp82s,1048
3
+ s2python/s2_parser.py,sha256=aDd_gt0YSa-OeYa9Ot8ZYNomOI61yU9uVBVem4-SBO0,4087
4
+ s2python/s2_validation_error.py,sha256=fdV2tdRhYslDStTw8Cvb3mly7PpLiCbXbrkfOe3n2_w,295
5
+ s2python/utils.py,sha256=SHYxnU4IlM6vN-WmnBEj-qMYG4_ykP93ZyvEtVIUEOU,212
6
+ s2python/validate_values_mixin.py,sha256=YHWXbOdom6v3DcVta2uY6TxHtT-Squn6rOrAzlmf96c,4230
7
+ s2python/version.py,sha256=w9Iw7QVvd8lme2wKwEbCo5IgetVjSfFBOOYAcA_Q0Ns,18
8
+ s2python/common/__init__.py,sha256=OO5eEuRFNB29yoChcXmKYqimsmJ29nAunb3xTUtJnU0,1443
9
+ s2python/common/duration.py,sha256=WtPr2GJAZ0lkKW6yxKTHsN8QxTonQ3xQIlxmK68bv4g,648
10
+ s2python/common/handshake.py,sha256=yVItASWui00KHewhk1kf9J-APcLNPoPJ4ifNI8NOlgg,433
11
+ s2python/common/handshake_response.py,sha256=zIgmBaNZD5_GK0yhc8hInPeO-FCtqC03Gd2D9GZ05qM,497
12
+ s2python/common/instruction_status_update.py,sha256=qqGWn6eX34GaZy2ikJ1XG2HIvR8DgfATpqKDRafHFds,574
13
+ s2python/common/number_range.py,sha256=uTtrTctuqFK8dIgOwP9ctqRyUq-ZRGHoIzZgGzNNkl0,1150
14
+ s2python/common/power_forecast.py,sha256=jBtoUROMugvj0nhYZbnBmi9_h8XpjeBp3p93SUawNaQ,679
15
+ s2python/common/power_forecast_element.py,sha256=miSykpw6wtU8opQS_REw1YxB8z_2or7QylRpVkVzSYg,774
16
+ s2python/common/power_forecast_value.py,sha256=mWrinzXl9Hv8Wwz1u7zPlM-q67QEDHab7ZE6yBSYMzg,362
17
+ s2python/common/power_measurement.py,sha256=qi00R2GT2Hg1prJ4pP2frDzUqKpJQDOehUY66fYMo4Q,657
18
+ s2python/common/power_range.py,sha256=XA_2SuAL3s3ahtLOrEFYtnhmYFg-xsZQ74_WeGkJaVI,783
19
+ s2python/common/power_value.py,sha256=yUw5vE4SUjgJwhQd7q8q3k9-0ylEBuWL3ksNuZ_11SA,314
20
+ s2python/common/reception_status.py,sha256=lEMQf1_22rxYFGcHEsWosnybtr2I-EneoptqJARmqoo,481
21
+ s2python/common/resource_manager_details.py,sha256=Wxs8C9PEeZdOofJvzYQ4PwbXvi_YXvnUbqNnzgTDBsE,933
22
+ s2python/common/revoke_object.py,sha256=Lu6jzUvLjBwtcRK8Me4PGoo87JnwRTTJYCtNEBF4F_0,457
23
+ s2python/common/role.py,sha256=_OQP-sZ_T_qOP_Qf44cYoxVMRJYToMj-ZRCxyQI7TJ4,278
24
+ s2python/common/select_control_type.py,sha256=NWdo44cN9xmEPMmuy5bRoNgJnGLA9sBtUToloolteGE,497
25
+ s2python/common/session_request.py,sha256=bo9qsjWAbDhdRxEp0-bJ3rC61N8fFv6M-IU0-ljo73E,473
26
+ s2python/common/support.py,sha256=cARbi4LIf0g64jhZ5gcqeWJLJkM7YBHt1OAZDeRQV0M,1015
27
+ s2python/common/timer.py,sha256=rcCK5wZvsSNEe-0MislFg8OPnhkqKpQjq9gD_vt-z9c,427
28
+ s2python/common/transition.py,sha256=SLkVT1BdWqhk_MAGEc3aWEHy6a2onSTgEuNwblZ55Q4,537
29
+ s2python/frbc/__init__.py,sha256=4oYGzsgbaFB4KLV-t8fIAtyaMK5UCEzVr5lALwDamcU,1104
30
+ s2python/frbc/frbc_actuator_description.py,sha256=eE4WFXB1_60DS717B-J5lSgluQadB__a5Jj1ikJRl5w,6705
31
+ s2python/frbc/frbc_actuator_status.py,sha256=FpHcBmdrxrAxh9Vbp6u2rOmJj7HGJqApVM4MDrmfmvs,507
32
+ s2python/frbc/frbc_fill_level_target_profile.py,sha256=xAgJ4WR4Fs-I8LsOpbsQHk5CKyjydMl1TUovgiyN6Tk,890
33
+ s2python/frbc/frbc_fill_level_target_profile_element.py,sha256=6Aoh2Gb7kZBwa1rGmHIw5fphkH5uYH9bGeLaQFro8rc,818
34
+ s2python/frbc/frbc_instruction.py,sha256=eeSDW4mdI-KMx-8htSBSk59GsQ5V-UDYWcCZCiynfJc,483
35
+ s2python/frbc/frbc_leakage_behaviour.py,sha256=XpgVugZoc6CRLHGUHfJHgtIXb03Fwk8KbwTkqsTG5XE,778
36
+ s2python/frbc/frbc_leakage_behaviour_element.py,sha256=AJ0La_3jnHuXYgwvXA32lOB41dP8SOXpiHfQuEsOr3w,623
37
+ s2python/frbc/frbc_operation_mode.py,sha256=P6Nq28AUxplhhyeuQaDKBxGBoM-uCiGC5rhwqiL66r0,1908
38
+ s2python/frbc/frbc_operation_mode_element.py,sha256=wQsLskoFV99U9FhJOVeerz3ej_frfajWvwaVpsjKsc8,1066
39
+ s2python/frbc/frbc_storage_description.py,sha256=OtY830EHP1m4JxHNKfA3drJ6q-akgSSEP6ncd8VxmWo,588
40
+ s2python/frbc/frbc_storage_status.py,sha256=Z2Oppbzv3fcJJGqnmZBoXKUi8JQLoOjt5wUof15aSC4,499
41
+ s2python/frbc/frbc_system_description.py,sha256=d5QRik3nuhhudx7CT3YwuMRv4353JMoE9qehiYeupnE,994
42
+ s2python/frbc/frbc_timer_status.py,sha256=rMdEoZhAO0S5_fNN0VjgtZSGCgCB50AymEV4Ym8HRE8,483
43
+ s2python/frbc/frbc_usage_forecast.py,sha256=5G4zl9e7TBfGYFCZ7K-HdR_QZTVOxYVS43wcuXenrjs,728
44
+ s2python/frbc/frbc_usage_forecast_element.py,sha256=7wYAlNPNStW485-yVMqjkoQlHnWmG_I5ILCF2UhMaCU,566
45
+ s2python/generated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
+ s2python/generated/gen_s2.py,sha256=5efQyo-hqCYa9Rm09V0C-ifbIFy89Ywoz8OX1Xm4GEM,62370
47
+ s2_python-0.1.3.dist-info/METADATA,sha256=wFwlXOSLIk48DFAbN3T2_GgzxH2XEQ0Cn3Sd3OG2UkA,3290
48
+ s2_python-0.1.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
49
+ s2_python-0.1.3.dist-info/entry_points.txt,sha256=feX-xmgJZgSe5-jxMgFKPKCJz4Ys3eQcGrsXsirNZyM,61
50
+ s2_python-0.1.3.dist-info/top_level.txt,sha256=OLFq0oDhr77Mp-EYLEcWk5P3jvooOt4IHkTI5KYJMc8,9
51
+ s2_python-0.1.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
s2python/__init__.py CHANGED
@@ -2,7 +2,7 @@ from importlib.metadata import PackageNotFoundError, version # pragma: no cover
2
2
 
3
3
  try:
4
4
  # Change here if project is renamed and does not equal the package name
5
- dist_name = "s2-python"
5
+ dist_name = "s2-python" # pylint: disable=invalid-name
6
6
  __version__ = version(dist_name)
7
7
  except PackageNotFoundError: # pragma: no cover
8
8
  __version__ = "unknown"
@@ -1,32 +1,33 @@
1
- from s2python.generated.gen_s2 import (
2
- RoleType,
3
- CommodityQuantity,
4
- Commodity,
5
- InstructionStatus,
6
- ReceptionStatusValues,
7
- EnergyManagementRole,
8
- SessionRequestType,
9
- ControlType,
10
- Currency,
11
- RevokableObjects,
12
- )
1
+ # noqa
13
2
 
14
3
  from s2python.common.duration import Duration
15
- from s2python.common.role import Role
16
4
  from s2python.common.handshake import Handshake
17
5
  from s2python.common.handshake_response import HandshakeResponse
18
6
  from s2python.common.instruction_status_update import InstructionStatusUpdate
19
7
  from s2python.common.number_range import NumberRange
20
- from s2python.common.power_forecast_value import PowerForecastValue
21
- from s2python.common.power_forecast_element import PowerForecastElement
22
8
  from s2python.common.power_forecast import PowerForecast
23
- from s2python.common.power_value import PowerValue
9
+ from s2python.common.power_forecast_element import PowerForecastElement
10
+ from s2python.common.power_forecast_value import PowerForecastValue
24
11
  from s2python.common.power_measurement import PowerMeasurement
25
12
  from s2python.common.power_range import PowerRange
13
+ from s2python.common.power_value import PowerValue
26
14
  from s2python.common.reception_status import ReceptionStatus
27
15
  from s2python.common.resource_manager_details import ResourceManagerDetails
28
16
  from s2python.common.revoke_object import RevokeObject
17
+ from s2python.common.role import Role
29
18
  from s2python.common.select_control_type import SelectControlType
30
19
  from s2python.common.session_request import SessionRequest
31
20
  from s2python.common.timer import Timer
32
21
  from s2python.common.transition import Transition
22
+ from s2python.generated.gen_s2 import (
23
+ Commodity,
24
+ CommodityQuantity,
25
+ ControlType,
26
+ Currency, # noqa F401
27
+ EnergyManagementRole, # noqa F401
28
+ InstructionStatus, # noqa F401
29
+ ReceptionStatusValues, # noqa F401
30
+ RevokableObjects, # noqa F401
31
+ RoleType, # noqa F401
32
+ SessionRequestType, # noqa F401
33
+ )
@@ -1,15 +1,12 @@
1
- from datetime import timedelta
2
1
  import math
2
+ from datetime import timedelta
3
3
 
4
4
  from s2python.generated.gen_s2 import Duration as GenDuration
5
- from s2python.validate_values_mixin import (
6
- catch_and_convert_exceptions,
7
- ValidateValuesMixin,
8
- )
5
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
9
6
 
10
7
 
11
8
  @catch_and_convert_exceptions
12
- class Duration(GenDuration, ValidateValuesMixin["Duration"]):
9
+ class Duration(GenDuration, S2Message["Duration"]):
13
10
  def to_timedelta(self) -> timedelta:
14
11
  return timedelta(milliseconds=self.__root__)
15
12
 
@@ -1,15 +1,14 @@
1
- import uuid
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
2
4
 
3
5
  from s2python.generated.gen_s2 import Handshake as GenHandshake
4
- from s2python.validate_values_mixin import (
5
- catch_and_convert_exceptions,
6
- ValidateValuesMixin,
7
- )
6
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
8
7
 
9
8
 
10
9
  @catch_and_convert_exceptions
11
- class Handshake(GenHandshake, ValidateValuesMixin["Handshake"]):
10
+ class Handshake(GenHandshake, S2Message["Handshake"]):
12
11
  class Config(GenHandshake.Config):
13
12
  validate_assignment = True
14
13
 
15
- message_id: uuid.UUID = GenHandshake.__fields__["message_id"].field_info # type: ignore[assignment]
14
+ message_type: Literal["Handshake"] = Field(default="Handshake")
@@ -1,15 +1,14 @@
1
- import uuid
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
2
4
 
3
5
  from s2python.generated.gen_s2 import HandshakeResponse as GenHandshakeResponse
4
- from s2python.validate_values_mixin import (
5
- catch_and_convert_exceptions,
6
- ValidateValuesMixin,
7
- )
6
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
8
7
 
9
8
 
10
9
  @catch_and_convert_exceptions
11
- class HandshakeResponse(GenHandshakeResponse, ValidateValuesMixin["HandshakeResponse"]):
10
+ class HandshakeResponse(GenHandshakeResponse, S2Message["HandshakeResponse"]):
12
11
  class Config(GenHandshakeResponse.Config):
13
12
  validate_assignment = True
14
13
 
15
- message_id: uuid.UUID = GenHandshakeResponse.__fields__["message_id"].field_info # type: ignore[assignment]
14
+ message_type: Literal["HandshakeResponse"] = Field(default="HandshakeResponse")
@@ -1,22 +1,20 @@
1
- import uuid
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
2
4
 
3
5
  from s2python.generated.gen_s2 import (
4
6
  InstructionStatusUpdate as GenInstructionStatusUpdate,
5
7
  )
6
- from s2python.validate_values_mixin import (
7
- catch_and_convert_exceptions,
8
- ValidateValuesMixin,
9
- )
8
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
10
9
 
11
10
 
12
11
  @catch_and_convert_exceptions
13
12
  class InstructionStatusUpdate(
14
- GenInstructionStatusUpdate, ValidateValuesMixin["InstructionStatusUpdate"]
13
+ GenInstructionStatusUpdate, S2Message["InstructionStatusUpdate"]
15
14
  ):
16
15
  class Config(GenInstructionStatusUpdate.Config):
17
16
  validate_assignment = True
18
17
 
19
- message_id: uuid.UUID = GenInstructionStatusUpdate.__fields__["message_id"].field_info # type: ignore[assignment]
20
- instruction_id: uuid.UUID = GenInstructionStatusUpdate.__fields__[
21
- "instruction_id"
22
- ].field_info # type: ignore[assignment]
18
+ message_type: Literal["InstructionStatusUpdate"] = Field(
19
+ default="InstructionStatusUpdate"
20
+ )
@@ -2,20 +2,20 @@ from typing import Any, Dict
2
2
 
3
3
  from pydantic import root_validator
4
4
 
5
- from s2python.validate_values_mixin import (
6
- ValidateValuesMixin,
7
- catch_and_convert_exceptions,
8
- )
9
5
  from s2python.generated.gen_s2 import NumberRange as GenNumberRange
6
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
10
7
 
11
8
 
12
9
  @catch_and_convert_exceptions
13
- class NumberRange(GenNumberRange, ValidateValuesMixin["NumberRange"]):
10
+ class NumberRange(GenNumberRange, S2Message["NumberRange"]):
14
11
  class Config(GenNumberRange.Config):
15
12
  validate_assignment = True
16
13
 
17
14
  @root_validator(pre=False)
18
- def validate_start_end_order(cls, values: Dict[str, Any]) -> Dict[str, Any]:
15
+ @classmethod
16
+ def validate_start_end_order( # pylint: disable=duplicate-code
17
+ cls, values: Dict[str, Any]
18
+ ) -> Dict[str, Any]:
19
19
  if values.get("start_of_range", 0.0) > values.get("end_of_range", 0.0):
20
20
  raise ValueError(
21
21
  cls, "start_of_range should not be higher than end_of_range"
@@ -23,14 +23,14 @@ class NumberRange(GenNumberRange, ValidateValuesMixin["NumberRange"]):
23
23
 
24
24
  return values
25
25
 
26
- def __hash__(self):
26
+ def __hash__(self) -> int:
27
27
  return hash(f"{self.start_of_range}|{self.end_of_range}")
28
28
 
29
- def __eq__(self, other):
29
+ def __eq__(self, other: Any) -> bool:
30
30
  if isinstance(other, NumberRange):
31
31
  return (
32
32
  self.start_of_range == other.start_of_range
33
33
  and self.end_of_range == other.end_of_range
34
34
  )
35
- else:
36
- return False
35
+
36
+ return False
@@ -1,20 +1,18 @@
1
- from typing import List
2
- import uuid
1
+ from typing import List, Literal
3
2
 
4
- from s2python.common import PowerForecastElement
3
+ from pydantic import Field
4
+
5
+ from s2python.common.power_forecast_element import PowerForecastElement
5
6
  from s2python.generated.gen_s2 import PowerForecast as GenPowerForecast
6
- from s2python.validate_values_mixin import (
7
- catch_and_convert_exceptions,
8
- ValidateValuesMixin,
9
- )
7
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
10
8
 
11
9
 
12
10
  @catch_and_convert_exceptions
13
- class PowerForecast(GenPowerForecast, ValidateValuesMixin["PowerForecast"]):
11
+ class PowerForecast(GenPowerForecast, S2Message["PowerForecast"]):
14
12
  class Config(GenPowerForecast.Config):
15
13
  validate_assignment = True
16
14
 
17
- message_id: uuid.UUID = GenPowerForecast.__fields__["message_id"].field_info # type: ignore[assignment]
18
15
  elements: List[PowerForecastElement] = GenPowerForecast.__fields__[
19
16
  "elements"
20
17
  ].field_info # type: ignore[assignment]
18
+ message_type: Literal["PowerForecast"] = Field(default="PowerForecast")
@@ -1,17 +1,13 @@
1
1
  from typing import List
2
2
 
3
+ from s2python.common.duration import Duration
4
+ from s2python.common.power_forecast_value import PowerForecastValue
3
5
  from s2python.generated.gen_s2 import PowerForecastElement as GenPowerForecastElement
4
- from s2python.validate_values_mixin import (
5
- catch_and_convert_exceptions,
6
- ValidateValuesMixin,
7
- )
8
- from s2python.common import Duration, PowerForecastValue
6
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
9
7
 
10
8
 
11
9
  @catch_and_convert_exceptions
12
- class PowerForecastElement(
13
- GenPowerForecastElement, ValidateValuesMixin["PowerForecastElement"]
14
- ):
10
+ class PowerForecastElement(GenPowerForecastElement, S2Message["PowerForecastElement"]):
15
11
  class Config(GenPowerForecastElement.Config):
16
12
  validate_assignment = True
17
13
 
@@ -1,13 +1,8 @@
1
1
  from s2python.generated.gen_s2 import PowerForecastValue as GenPowerForecastValue
2
- from s2python.validate_values_mixin import (
3
- catch_and_convert_exceptions,
4
- ValidateValuesMixin,
5
- )
2
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
6
3
 
7
4
 
8
5
  @catch_and_convert_exceptions
9
- class PowerForecastValue(
10
- GenPowerForecastValue, ValidateValuesMixin["PowerForecastValue"]
11
- ):
6
+ class PowerForecastValue(GenPowerForecastValue, S2Message["PowerForecastValue"]):
12
7
  class Config(GenPowerForecastValue.Config):
13
8
  validate_assignment = True
@@ -1,18 +1,16 @@
1
- from typing import List
2
- import uuid
1
+ from typing import List, Literal
3
2
 
4
- from s2python.common import PowerValue
3
+ from pydantic import Field
4
+
5
+ from s2python.common.power_value import PowerValue
5
6
  from s2python.generated.gen_s2 import PowerMeasurement as GenPowerMeasurement
6
- from s2python.validate_values_mixin import (
7
- catch_and_convert_exceptions,
8
- ValidateValuesMixin,
9
- )
7
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
10
8
 
11
9
 
12
10
  @catch_and_convert_exceptions
13
- class PowerMeasurement(GenPowerMeasurement, ValidateValuesMixin["PowerMeasurement"]):
11
+ class PowerMeasurement(GenPowerMeasurement, S2Message["PowerMeasurement"]):
14
12
  class Config(GenPowerMeasurement.Config):
15
13
  validate_assignment = True
16
14
 
17
- message_id: uuid.UUID = GenPowerMeasurement.__fields__["message_id"].field_info # type: ignore[assignment]
18
15
  values: List[PowerValue] = GenPowerMeasurement.__fields__["values"].field_info # type: ignore[assignment]
16
+ message_type: Literal["PowerMeasurement"] = Field(default="PowerMeasurement")
@@ -3,19 +3,19 @@ from typing import Any, Dict
3
3
  from pydantic import root_validator
4
4
 
5
5
  from s2python.generated.gen_s2 import PowerRange as GenPowerRange
6
- from s2python.validate_values_mixin import (
7
- ValidateValuesMixin,
8
- catch_and_convert_exceptions,
9
- )
6
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
10
7
 
11
8
 
12
9
  @catch_and_convert_exceptions
13
- class PowerRange(GenPowerRange, ValidateValuesMixin["PowerRange"]):
10
+ class PowerRange(GenPowerRange, S2Message["PowerRange"]):
14
11
  class Config(GenPowerRange.Config):
15
12
  validate_assignment = True
16
13
 
17
14
  @root_validator(pre=False)
18
- def validate_start_end_order(cls, values: Dict[str, Any]) -> Dict[str, Any]:
15
+ @classmethod
16
+ def validate_start_end_order(
17
+ cls, values: Dict[str, Any]
18
+ ) -> Dict[str, Any]: # pylint: disable=duplicate-code
19
19
  if values.get("start_of_range", 0.0) > values.get("end_of_range", 0.0):
20
20
  raise ValueError(
21
21
  cls, "start_of_range should not be higher than end_of_range"
@@ -1,11 +1,8 @@
1
1
  from s2python.generated.gen_s2 import PowerValue as GenPowerValue
2
- from s2python.validate_values_mixin import (
3
- catch_and_convert_exceptions,
4
- ValidateValuesMixin,
5
- )
2
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
6
3
 
7
4
 
8
5
  @catch_and_convert_exceptions
9
- class PowerValue(GenPowerValue, ValidateValuesMixin["PowerValue"]):
6
+ class PowerValue(GenPowerValue, S2Message["PowerValue"]):
10
7
  class Config(GenPowerValue.Config):
11
8
  validate_assignment = True
@@ -1,17 +1,14 @@
1
- import uuid
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
2
4
 
3
5
  from s2python.generated.gen_s2 import ReceptionStatus as GenReceptionStatus
4
- from s2python.validate_values_mixin import (
5
- catch_and_convert_exceptions,
6
- ValidateValuesMixin,
7
- )
6
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
8
7
 
9
8
 
10
9
  @catch_and_convert_exceptions
11
- class ReceptionStatus(GenReceptionStatus, ValidateValuesMixin["ReceptionStatus"]):
10
+ class ReceptionStatus(GenReceptionStatus, S2Message["ReceptionStatus"]):
12
11
  class Config(GenReceptionStatus.Config):
13
12
  validate_assignment = True
14
13
 
15
- subject_message_id: uuid.UUID = GenReceptionStatus.__fields__[
16
- "subject_message_id"
17
- ].field_info # type: ignore[assignment]
14
+ message_type: Literal["ReceptionStatus"] = Field(default="ReceptionStatus")
@@ -1,19 +1,18 @@
1
- from typing import List
2
- import uuid
1
+ from typing import List, Literal
3
2
 
4
- from s2python.common import Duration, Role
3
+ from pydantic import Field
4
+
5
+ from s2python.common.duration import Duration
6
+ from s2python.common.role import Role
5
7
  from s2python.generated.gen_s2 import (
6
8
  ResourceManagerDetails as GenResourceManagerDetails,
7
9
  )
8
- from s2python.validate_values_mixin import (
9
- catch_and_convert_exceptions,
10
- ValidateValuesMixin,
11
- )
10
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
12
11
 
13
12
 
14
13
  @catch_and_convert_exceptions
15
14
  class ResourceManagerDetails(
16
- GenResourceManagerDetails, ValidateValuesMixin["ResourceManagerDetails"]
15
+ GenResourceManagerDetails, S2Message["ResourceManagerDetails"]
17
16
  ):
18
17
  class Config(GenResourceManagerDetails.Config):
19
18
  validate_assignment = True
@@ -21,6 +20,8 @@ class ResourceManagerDetails(
21
20
  instruction_processing_delay: Duration = GenResourceManagerDetails.__fields__[
22
21
  "instruction_processing_delay"
23
22
  ].field_info # type: ignore[assignment]
24
- message_id: uuid.UUID = GenResourceManagerDetails.__fields__["message_id"].field_info # type: ignore[assignment]
25
- resource_id: uuid.UUID = GenResourceManagerDetails.__fields__["resource_id"].field_info # type: ignore[assignment]
23
+
26
24
  roles: List[Role] = GenResourceManagerDetails.__fields__["roles"].field_info # type: ignore[assignment]
25
+ message_type: Literal["ResourceManagerDetails"] = Field(
26
+ default="ResourceManagerDetails"
27
+ )
@@ -1,16 +1,14 @@
1
- import uuid
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
2
4
 
3
5
  from s2python.generated.gen_s2 import RevokeObject as GenRevokeObject
4
- from s2python.validate_values_mixin import (
5
- catch_and_convert_exceptions,
6
- ValidateValuesMixin,
7
- )
6
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
8
7
 
9
8
 
10
9
  @catch_and_convert_exceptions
11
- class RevokeObject(GenRevokeObject, ValidateValuesMixin["RevokeObject"]):
10
+ class RevokeObject(GenRevokeObject, S2Message["RevokeObject"]):
12
11
  class Config(GenRevokeObject.Config):
13
12
  validate_assignment = True
14
13
 
15
- message_id: uuid.UUID = GenRevokeObject.__fields__["message_id"].field_info # type: ignore[assignment]
16
- object_id: uuid.UUID = GenRevokeObject.__fields__["object_id"].field_info # type: ignore[assignment]
14
+ message_type: Literal["RevokeObject"] = Field(default="RevokeObject")
s2python/common/role.py CHANGED
@@ -1,11 +1,8 @@
1
1
  from s2python.generated.gen_s2 import Role as GenRole
2
- from s2python.validate_values_mixin import (
3
- ValidateValuesMixin,
4
- catch_and_convert_exceptions,
5
- )
2
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
6
3
 
7
4
 
8
5
  @catch_and_convert_exceptions
9
- class Role(GenRole, ValidateValuesMixin["Role"]):
6
+ class Role(GenRole, S2Message["Role"]):
10
7
  class Config(GenRole.Config):
11
8
  validate_assignment = True
@@ -1,15 +1,14 @@
1
- import uuid
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
2
4
 
3
5
  from s2python.generated.gen_s2 import SelectControlType as GenSelectControlType
4
- from s2python.validate_values_mixin import (
5
- catch_and_convert_exceptions,
6
- ValidateValuesMixin,
7
- )
6
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
8
7
 
9
8
 
10
9
  @catch_and_convert_exceptions
11
- class SelectControlType(GenSelectControlType, ValidateValuesMixin["SelectControlType"]):
10
+ class SelectControlType(GenSelectControlType, S2Message["SelectControlType"]):
12
11
  class Config(GenSelectControlType.Config):
13
12
  validate_assignment = True
14
13
 
15
- message_id: uuid.UUID = GenSelectControlType.__fields__["message_id"].field_info # type: ignore[assignment]
14
+ message_type: Literal["SelectControlType"] = Field(default="SelectControlType")
@@ -1,15 +1,14 @@
1
- import uuid
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
2
4
 
3
5
  from s2python.generated.gen_s2 import SessionRequest as GenSessionRequest
4
- from s2python.validate_values_mixin import (
5
- catch_and_convert_exceptions,
6
- ValidateValuesMixin,
7
- )
6
+ from s2python.validate_values_mixin import S2Message, catch_and_convert_exceptions
8
7
 
9
8
 
10
9
  @catch_and_convert_exceptions
11
- class SessionRequest(GenSessionRequest, ValidateValuesMixin["SessionRequest"]):
10
+ class SessionRequest(GenSessionRequest, S2Message["SessionRequest"]):
12
11
  class Config(GenSessionRequest.Config):
13
12
  validate_assignment = True
14
13
 
15
- message_id: uuid.UUID = GenSessionRequest.__fields__["message_id"].field_info # type: ignore[assignment]
14
+ message_type: Literal["SessionRequest"] = Field(default="SessionRequest")