Skip to content

Commit

Permalink
Merge branch 'master' into revert_type_hint_change_for_DataTransfer_data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmclarty authored Jan 17, 2024
2 parents 9d54134 + 9f1ab29 commit 31a335a
Show file tree
Hide file tree
Showing 6 changed files with 517 additions and 260 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change log

- [#447](https://github.com/mobilityhouse/ocpp/issues/447) Make formatting of enums in py3.11 consistent with earlier Python versions
## 0.26.0 (2024-01-17)

- [#544](https://github.com/mobilityhouse/ocpp/issues/544) ocpp/charge_point.py - Pass `Call.unique_id` to the `on` and `after` routing handlers.
- [#559](https://github.com/mobilityhouse/ocpp/issues/559) Update project dependencies as of 22-12-2023
- [#447](https://github.com/mobilityhouse/ocpp/issues/447) v16, v201 - Make formatting of enums in py3.11 consistent with earlier Python versions
- [#421](https://github.com/mobilityhouse/ocpp/issues/421) Type of v16.datatypes.SampledValue.context is incorrect

## 0.25.0 (2024-01-08)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = "Auke Willem Oosterhoff"

# The full version, including alpha/beta/rc tags
release = "0.25.0"
release = "0.26.0"


# -- General configuration ---------------------------------------------------
Expand Down
19 changes: 16 additions & 3 deletions ocpp/charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,15 @@ async def _handle_call(self, msg):
handler = handlers["_on_action"]
except KeyError:
_raise_key_error(msg.action, self._ocpp_version)

handler_signature = inspect.signature(handler)
call_unique_id_required = "call_unique_id" in handler_signature.parameters
try:
response = handler(**snake_case_payload)
# call_unique_id should be passed as kwarg only if is defined explicitly
# in the handler signature
if call_unique_id_required:
response = handler(**snake_case_payload, call_unique_id=msg.unique_id)
else:
response = handler(**snake_case_payload)
if inspect.isawaitable(response):
response = await response
except Exception as e:
Expand Down Expand Up @@ -259,9 +265,16 @@ async def _handle_call(self, msg):

try:
handler = handlers["_after_action"]
handler_signature = inspect.signature(handler)
call_unique_id_required = "call_unique_id" in handler_signature.parameters
# call_unique_id should be passed as kwarg only if is defined explicitly
# in the handler signature
if call_unique_id_required:
response = handler(**snake_case_payload, call_unique_id=msg.unique_id)
else:
response = handler(**snake_case_payload)
# Create task to avoid blocking when making a call inside the
# after handler
response = handler(**snake_case_payload)
if inspect.isawaitable(response):
asyncio.ensure_future(response)
except KeyError:
Expand Down
Loading

0 comments on commit 31a335a

Please sign in to comment.