From 92b94000e6f3a253181796031b8f829b030e2323 Mon Sep 17 00:00:00 2001 From: Wafa Yahyaoui <143813203+wafa-yah@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:12:47 +0100 Subject: [PATCH 1/9] Update readme - ocpp 2 edition 3 is supported (#686) From the readme in the ocpp 2.0.1 edition 3 zipfile https://openchargealliance.org/my-oca/ocpp/: For historical reasons not all documents have the same release date. OCPP 2.0.1 Edition 3 is the same as OCPP 2.0.1 Edition 2 including all errata up and until OCPP-2.0.1_edition2_errata_2024-04 (2024-04-30). The errata do not affect any schemas of OCPP messages. The errata do contain changes to requirements or even new requirements, but only in cases where a requirement contains an obvious error and would not or could not be implemented literally. New requirements were only added when they were already implicitly there. No code changes needed to library then => Updated readme to mention edition 3 support. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index aa40c0726..9832ff545 100644 --- a/README.rst +++ b/README.rst @@ -11,7 +11,7 @@ OCPP ---- Python package implementing the JSON version of the Open Charge Point Protocol -(OCPP). Currently OCPP 1.6 (errata v4), OCPP 2.0.1 (Edition 2 FINAL, 2022-12-15) +(OCPP). Currently OCPP 1.6 (errata v4), OCPP 2.0.1 (Edition 2 FINAL, 2022-12-15 and Edition 3 errata 2024-11) are supported. You can find the documentation on `rtd`_. From 0dc23fb589af2cd1eb2566028e22f35af8f3475e Mon Sep 17 00:00:00 2001 From: astrand Date: Sat, 7 Dec 2024 06:30:11 +0100 Subject: [PATCH 2/9] Disable threads if messages.ASYNC_VALIDATION = False (#678) See discussion at https://github.com/mobilityhouse/ocpp/pull/676 --------- Co-authored-by: Peter Astrand Co-authored-by: Patrick Roelke --- ocpp/charge_point.py | 17 +++++---------- ocpp/messages.py | 15 ++++++++++++- tests/test_exceptions.py | 6 +++--- tests/test_messages.py | 46 ++++++++++++++++++++++++++++++---------- 4 files changed, 57 insertions(+), 27 deletions(-) diff --git a/ocpp/charge_point.py b/ocpp/charge_point.py index 7314804b1..0f3ceacff 100644 --- a/ocpp/charge_point.py +++ b/ocpp/charge_point.py @@ -295,9 +295,8 @@ async def _handle_call(self, msg): return if not handlers.get("_skip_schema_validation", False): - await asyncio.get_event_loop().run_in_executor( - None, validate_payload, msg, self._ocpp_version - ) + await validate_payload(msg, self._ocpp_version) + # OCPP uses camelCase for the keys in the payload. It's more pythonic # to use snake_case for keyword arguments. Therefore the keys must be # 'translated'. Some examples: @@ -344,9 +343,7 @@ async def _handle_call(self, msg): response = msg.create_call_result(camel_case_payload) if not handlers.get("_skip_schema_validation", False): - await asyncio.get_event_loop().run_in_executor( - None, validate_payload, response, self._ocpp_version - ) + await validate_payload(response, self._ocpp_version) await self._send(response.to_json()) @@ -415,9 +412,7 @@ async def call( ) if not skip_schema_validation: - await asyncio.get_event_loop().run_in_executor( - None, validate_payload, call, self._ocpp_version - ) + await validate_payload(call, self._ocpp_version) # Use a lock to prevent make sure that only 1 message can be send at a # a time. @@ -440,9 +435,7 @@ async def call( raise response.to_exception() elif not skip_schema_validation: response.action = call.action - await asyncio.get_event_loop().run_in_executor( - None, validate_payload, response, self._ocpp_version - ) + await validate_payload(response, self._ocpp_version) snake_case_payload = camel_to_snake_case(response.payload) # Create the correct Payload instance based on the received payload. If diff --git a/ocpp/messages.py b/ocpp/messages.py index 3e82ff32d..ac70419df 100644 --- a/ocpp/messages.py +++ b/ocpp/messages.py @@ -1,7 +1,9 @@ """ Module containing classes that model the several OCPP messages types. It also contain some helper functions for packing and unpacking messages. """ + from __future__ import annotations +import asyncio import decimal import json import os @@ -24,6 +26,8 @@ _validators: Dict[str, Draft4Validator] = {} +ASYNC_VALIDATION = True + class _DecimalEncoder(json.JSONEncoder): """Encode values of type `decimal.Decimal` using 1 decimal point. @@ -169,8 +173,17 @@ def get_validator( return _validators[cache_key] -def validate_payload(message: Union[Call, CallResult], ocpp_version: str) -> None: +async def validate_payload(message: Union[Call, CallResult], ocpp_version: str) -> None: """Validate the payload of the message using JSON schemas.""" + if ASYNC_VALIDATION: + await asyncio.get_event_loop().run_in_executor( + None, _validate_payload, message, ocpp_version + ) + else: + _validate_payload(message, ocpp_version) + + +def _validate_payload(message: Union[Call, CallResult], ocpp_version: str) -> None: if type(message) not in [Call, CallResult]: raise ValidationError( "Payload can't be validated because message " diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 35c3c4ebc..59beb5fa2 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -5,7 +5,7 @@ ProtocolError, TypeConstraintViolationError, ) -from ocpp.messages import Call, validate_payload +from ocpp.messages import Call, _validate_payload def test_exception_with_error_details(): @@ -36,7 +36,7 @@ def test_exception_show_triggered_message_type_constraint(): ) with pytest.raises(TypeConstraintViolationError) as exception_info: - validate_payload(call, "1.6") + _validate_payload(call, "1.6") assert ocpp_message in str(exception_info.value) @@ -54,5 +54,5 @@ def test_exception_show_triggered_message_format(): ) with pytest.raises(FormatViolationError) as exception_info: - validate_payload(call, "1.6") + _validate_payload(call, "1.6") assert ocpp_message in str(exception_info.value) diff --git a/tests/test_messages.py b/tests/test_messages.py index 4028a1e3f..343691aa3 100644 --- a/tests/test_messages.py +++ b/tests/test_messages.py @@ -1,11 +1,13 @@ import decimal import json +import threading from datetime import datetime import pytest from hypothesis import given from hypothesis.strategies import binary +import ocpp from ocpp.exceptions import ( FormatViolationError, NotImplementedError, @@ -21,6 +23,7 @@ CallResult, MessageType, _DecimalEncoder, + _validate_payload, _validators, get_validator, pack, @@ -137,7 +140,7 @@ def test_validate_set_charging_profile_payload(): }, ) - validate_payload(message, ocpp_version="1.6") + _validate_payload(message, ocpp_version="1.6") def test_validate_get_composite_profile_payload(): @@ -162,7 +165,7 @@ def test_validate_get_composite_profile_payload(): }, ) - validate_payload(message, ocpp_version="1.6") + _validate_payload(message, ocpp_version="1.6") @pytest.mark.parametrize("ocpp_version", ["1.6", "2.0.1"]) @@ -177,7 +180,7 @@ def test_validate_payload_with_valid_payload(ocpp_version): payload={"currentTime": datetime.now().isoformat()}, ) - validate_payload(message, ocpp_version=ocpp_version) + _validate_payload(message, ocpp_version=ocpp_version) def test_validate_payload_with_invalid_additional_properties_payload(): @@ -192,7 +195,7 @@ def test_validate_payload_with_invalid_additional_properties_payload(): ) with pytest.raises(FormatViolationError): - validate_payload(message, ocpp_version="1.6") + _validate_payload(message, ocpp_version="1.6") def test_validate_payload_with_invalid_type_payload(): @@ -212,7 +215,7 @@ def test_validate_payload_with_invalid_type_payload(): ) with pytest.raises(TypeConstraintViolationError): - validate_payload(message, ocpp_version="1.6") + _validate_payload(message, ocpp_version="1.6") def test_validate_payload_with_invalid_missing_property_payload(): @@ -232,7 +235,7 @@ def test_validate_payload_with_invalid_missing_property_payload(): ) with pytest.raises(ProtocolError): - validate_payload(message, ocpp_version="1.6") + _validate_payload(message, ocpp_version="1.6") def test_validate_payload_with_invalid_message_type_id(): @@ -241,7 +244,7 @@ def test_validate_payload_with_invalid_message_type_id(): a message type id other than 2, Call, or 3, CallError. """ with pytest.raises(ValidationError): - validate_payload(dict(), ocpp_version="1.6") + _validate_payload(dict(), ocpp_version="1.6") def test_validate_payload_with_non_existing_schema(): @@ -256,7 +259,7 @@ def test_validate_payload_with_non_existing_schema(): ) with pytest.raises(NotImplementedError): - validate_payload(message, ocpp_version="1.6") + _validate_payload(message, ocpp_version="1.6") def test_call_error_representation(): @@ -342,7 +345,7 @@ def test_serializing_custom_types(): ) try: - validate_payload(message, ocpp_version="1.6") + _validate_payload(message, ocpp_version="1.6") except TypeConstraintViolationError as error: # Before the fix, this call would fail with a TypError. Lack of any error # makes this test pass. @@ -376,7 +379,7 @@ def test_validate_meter_values_hertz(): }, ) - validate_payload(message, ocpp_version="1.6") + _validate_payload(message, ocpp_version="1.6") def test_validate_set_maxlength_violation_payload(): @@ -394,4 +397,25 @@ def test_validate_set_maxlength_violation_payload(): ) with pytest.raises(TypeConstraintViolationError): - validate_payload(message, ocpp_version="1.6") + _validate_payload(message, ocpp_version="1.6") + + +@pytest.mark.parametrize("use_threads", [False, True]) +@pytest.mark.asyncio +async def test_validate_payload_threads(use_threads): + """ + Test that threads usage can be configured + """ + message = CallResult( + unique_id="1234", + action="Heartbeat", + payload={"currentTime": datetime.now().isoformat()}, + ) + + assert threading.active_count() == 1 + ocpp.messages.ASYNC_VALIDATION = use_threads + await validate_payload(message, ocpp_version="1.6") + if use_threads: + assert threading.active_count() > 1 + else: + assert threading.active_count() == 1 From 3264a4812c24b5b6d60de6d33a78952bf7132932 Mon Sep 17 00:00:00 2001 From: drc38 <20024196+drc38@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:05:04 +1300 Subject: [PATCH 3/9] test python 3.13 --- .github/workflows/pull-request.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a2d782a36..4445b661e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -16,6 +16,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@master - name: Set up Python ${{ matrix.version }} From a0b4820e4ae9c4758d520d35136f014104c5b184 Mon Sep 17 00:00:00 2001 From: Mohit Jain Date: Wed, 16 Oct 2024 10:10:48 +0530 Subject: [PATCH 4/9] Added inactive issue workflow - Issues that are stale for 30 days will be marked as `stale` - Issues that are marked as `stale` for more than 14 days will be automatically closed. - No changes will be done to PRs --- .github/workflows/inactive-issue.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/inactive-issue.yml diff --git a/.github/workflows/inactive-issue.yml b/.github/workflows/inactive-issue.yml new file mode 100644 index 000000000..c84cd8a38 --- /dev/null +++ b/.github/workflows/inactive-issue.yml @@ -0,0 +1,22 @@ +name: Close inactive issues +on: + schedule: + - cron: "0 0 * * *" + +jobs: + close-issues: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/stale@v5 + with: + days-before-issue-stale: 30 + days-before-issue-close: 14 + stale-issue-label: "stale" + stale-issue-message: "This issue is stale because it has been open for 30 days with no activity." + close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." + days-before-pr-stale: -1 + days-before-pr-close: -1 + repo-token: ${{ secrets.GITHUB_TOKEN }} From 6ad8f56970dcb1a601cbed611c74fb94384ef311 Mon Sep 17 00:00:00 2001 From: Chad <34003459+mdwcrft@users.noreply.github.com> Date: Mon, 9 Dec 2024 08:48:52 +0000 Subject: [PATCH 5/9] bump to 2.0.0-rc.3 (#691) --- CHANGELOG.md | 14 ++++++++++++++ docs/source/conf.py | 2 +- pyproject.toml | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e65dedb43..0443ac90a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Change log +## 2.0.0-rc.3 (2024-12-09) +- [#665](https://github.com/mobilityhouse/ocpp/pull/665) chore: Updated Python setup action to version v5 by @jainmohit2001 +- [#663](https://github.com/mobilityhouse/ocpp/pull/663) bugfix: Changed total_cost type from Optional[int] to Optional[float] by @jainmohit2001 +- [#667](https://github.com/mobilityhouse/ocpp/pull/667) feat: Added optional logger param to ChargePoint class by @jainmohit2001 +- [#686](https://github.com/mobilityhouse/ocpp/pull/666) bugfix: Handling UnicodeDecodeError in unpack function by @jainmohit2001 +- [#668](https://github.com/mobilityhouse/ocpp/pull/668) chore: Update CODEOWNERS by @jainmohit2001 +- [#652](https://github.com/mobilityhouse/ocpp/pull/652) add executor to validate_payload by @drc38 +- [#629](https://github.com/mobilityhouse/ocpp/pull/629) fix typo for InternalError in exceptions.py by @hhuseyinpay +- [#679](https://github.com/mobilityhouse/ocpp/pull/679) Add issue templates by @mdwcrft +- [#686](https://github.com/mobilityhouse/ocpp/pull/686) Update readme - ocpp 2 edition 3 is supported by @wafa-yah +- [#678](https://github.com/mobilityhouse/ocpp/pull/678) Disable threads if messages.ASYNC_VALIDATION = False by @astrand +- [#685](https://github.com/mobilityhouse/ocpp/pull/685) Test with python 3.13 by @drc38 +- [#673](https://github.com/mobilityhouse/ocpp/pull/673) chore: Added inactive issue workflow by @jainmohit2001 + ## 2.0.0-rc.2 (2024-06-18) - [#315](https://github.com/mobilityhouse/ocpp/pull/315) Allow to skip schema validation in `ChargePoint.call()`. Thanks [@esiebert](https://github.com/esiebert)! diff --git a/docs/source/conf.py b/docs/source/conf.py index a17f17a84..8fb601e2e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,7 +23,7 @@ author = "Auke Willem Oosterhoff" # The full version, including alpha/beta/rc tags -release = "2.0.0-rc.2" +release = "2.0.0-rc.3" # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 427dd5f5d..a512f5e2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ocpp" -version = "2.0.0-rc.2" +version = "2.0.0-rc.3" description = "Python package implementing the JSON version of the Open Charge Point Protocol (OCPP)." authors = [ "André Duarte ", From cc0f2bec417e3be0bbcf847ce50f4ce8c96721ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:13:31 +0000 Subject: [PATCH 6/9] Bump black from 22.12.0 to 24.3.0 (#621) Bumps [black](https://github.com/psf/black) from 22.12.0 to 24.3.0.
Release notes

Sourced from black's releases.

24.3.0

Highlights

This release is a milestone: it fixes Black's first CVE security vulnerability. If you run Black on untrusted input, or if you habitually put thousands of leading tab characters in your docstrings, you are strongly encouraged to upgrade immediately to fix CVE-2024-21503.

This release also fixes a bug in Black's AST safety check that allowed Black to make incorrect changes to certain f-strings that are valid in Python 3.12 and higher.

Stable style

  • Don't move comments along with delimiters, which could cause crashes (#4248)
  • Strengthen AST safety check to catch more unsafe changes to strings. Previous versions of Black would incorrectly format the contents of certain unusual f-strings containing nested strings with the same quote type. Now, Black will crash on such strings until support for the new f-string syntax is implemented. (#4270)
  • Fix a bug where line-ranges exceeding the last code line would not work as expected (#4273)

Performance

  • Fix catastrophic performance on docstrings that contain large numbers of leading tab characters. This fixes CVE-2024-21503. (#4278)

Documentation

  • Note what happens when --check is used with --quiet (#4236)

24.2.0

Stable style

  • Fixed a bug where comments where mistakenly removed along with redundant parentheses (#4218)

Preview style

  • Move the hug_parens_with_braces_and_square_brackets feature to the unstable style due to an outstanding crash and proposed formatting tweaks (#4198)
  • Fixed a bug where base expressions caused inconsistent formatting of ** in tenary expression (#4154)
  • Checking for newline before adding one on docstring that is almost at the line limit (#4185)
  • Remove redundant parentheses in case statement if guards (#4214).

Configuration

... (truncated)

Changelog

Sourced from black's changelog.

24.3.0

Highlights

This release is a milestone: it fixes Black's first CVE security vulnerability. If you run Black on untrusted input, or if you habitually put thousands of leading tab characters in your docstrings, you are strongly encouraged to upgrade immediately to fix CVE-2024-21503.

This release also fixes a bug in Black's AST safety check that allowed Black to make incorrect changes to certain f-strings that are valid in Python 3.12 and higher.

Stable style

  • Don't move comments along with delimiters, which could cause crashes (#4248)
  • Strengthen AST safety check to catch more unsafe changes to strings. Previous versions of Black would incorrectly format the contents of certain unusual f-strings containing nested strings with the same quote type. Now, Black will crash on such strings until support for the new f-string syntax is implemented. (#4270)
  • Fix a bug where line-ranges exceeding the last code line would not work as expected (#4273)

Performance

  • Fix catastrophic performance on docstrings that contain large numbers of leading tab characters. This fixes CVE-2024-21503. (#4278)

Documentation

  • Note what happens when --check is used with --quiet (#4236)

24.2.0

Stable style

  • Fixed a bug where comments where mistakenly removed along with redundant parentheses (#4218)

Preview style

  • Move the hug_parens_with_braces_and_square_brackets feature to the unstable style due to an outstanding crash and proposed formatting tweaks (#4198)
  • Fixed a bug where base expressions caused inconsistent formatting of ** in tenary expression (#4154)
  • Checking for newline before adding one on docstring that is almost at the line limit (#4185)
  • Remove redundant parentheses in case statement if guards (#4214).

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=black&package-manager=pip&previous-version=22.12.0&new-version=24.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/mobilityhouse/ocpp/network/alerts).
> **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days. Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chad <34003459+mdwcrft@users.noreply.github.com> --- poetry.lock | 47 +++++++++++++++++++++++++++++------------------ pyproject.toml | 2 +- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/poetry.lock b/poetry.lock index f6ed80414..7448d57f0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -49,36 +49,47 @@ dev = ["freezegun (>=1.0,<2.0)", "pytest (>=6.0)", "pytest-cov"] [[package]] name = "black" -version = "22.12.0" +version = "24.3.0" description = "The uncompromising code formatter." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d"}, - {file = "black-22.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351"}, - {file = "black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f"}, - {file = "black-22.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4"}, - {file = "black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2"}, - {file = "black-22.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350"}, - {file = "black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d"}, - {file = "black-22.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc"}, - {file = "black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320"}, - {file = "black-22.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148"}, - {file = "black-22.12.0-py3-none-any.whl", hash = "sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf"}, - {file = "black-22.12.0.tar.gz", hash = "sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f"}, + {file = "black-24.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7d5e026f8da0322b5662fa7a8e752b3fa2dac1c1cbc213c3d7ff9bdd0ab12395"}, + {file = "black-24.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9f50ea1132e2189d8dff0115ab75b65590a3e97de1e143795adb4ce317934995"}, + {file = "black-24.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2af80566f43c85f5797365077fb64a393861a3730bd110971ab7a0c94e873e7"}, + {file = "black-24.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:4be5bb28e090456adfc1255e03967fb67ca846a03be7aadf6249096100ee32d0"}, + {file = "black-24.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4f1373a7808a8f135b774039f61d59e4be7eb56b2513d3d2f02a8b9365b8a8a9"}, + {file = "black-24.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aadf7a02d947936ee418777e0247ea114f78aff0d0959461057cae8a04f20597"}, + {file = "black-24.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c02e4ea2ae09d16314d30912a58ada9a5c4fdfedf9512d23326128ac08ac3d"}, + {file = "black-24.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:bf21b7b230718a5f08bd32d5e4f1db7fc8788345c8aea1d155fc17852b3410f5"}, + {file = "black-24.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:2818cf72dfd5d289e48f37ccfa08b460bf469e67fb7c4abb07edc2e9f16fb63f"}, + {file = "black-24.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4acf672def7eb1725f41f38bf6bf425c8237248bb0804faa3965c036f7672d11"}, + {file = "black-24.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7ed6668cbbfcd231fa0dc1b137d3e40c04c7f786e626b405c62bcd5db5857e4"}, + {file = "black-24.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:56f52cfbd3dabe2798d76dbdd299faa046a901041faf2cf33288bc4e6dae57b5"}, + {file = "black-24.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:79dcf34b33e38ed1b17434693763301d7ccbd1c5860674a8f871bd15139e7837"}, + {file = "black-24.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e19cb1c6365fd6dc38a6eae2dcb691d7d83935c10215aef8e6c38edee3f77abd"}, + {file = "black-24.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65b76c275e4c1c5ce6e9870911384bff5ca31ab63d19c76811cb1fb162678213"}, + {file = "black-24.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:b5991d523eee14756f3c8d5df5231550ae8993e2286b8014e2fdea7156ed0959"}, + {file = "black-24.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c45f8dff244b3c431b36e3224b6be4a127c6aca780853574c00faf99258041eb"}, + {file = "black-24.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6905238a754ceb7788a73f02b45637d820b2f5478b20fec82ea865e4f5d4d9f7"}, + {file = "black-24.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7de8d330763c66663661a1ffd432274a2f92f07feeddd89ffd085b5744f85e7"}, + {file = "black-24.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:7bb041dca0d784697af4646d3b62ba4a6b028276ae878e53f6b4f74ddd6db99f"}, + {file = "black-24.3.0-py3-none-any.whl", hash = "sha256:41622020d7120e01d377f74249e677039d20e6344ff5851de8a10f11f513bf93"}, + {file = "black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f"}, ] [package.dependencies] click = ">=8.0.0" mypy-extensions = ">=0.4.3" +packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} -typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} [package.extras] colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] +d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] @@ -1139,4 +1150,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "48e5f44241d0f3102294f55c06ac54da9c72e37f47e618375b038bc78db70e66" +content-hash = "15a6df761b9c7a9c73ae8a1bcac89c616c4e532231cb1fdd2951980c045273d2" diff --git a/pyproject.toml b/pyproject.toml index a512f5e2b..876547461 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ pytest = "^7" pytest-asyncio = "^0.20.3" pytest-cov = "^4.0.0" sphinx = "^2.4.5" -black = "^22" +black = "^24" isort = "^5" flake8 = "^5" hypothesis = "^6.112.2" From db9135559acd3eb049b676745ea949190fcbf422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 9 Dec 2024 14:26:21 +0100 Subject: [PATCH 7/9] ci: ensure the matching poetry version is used (#693) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * We should not be updating dependencies in CI. Hence we should remove the `poetry update` command * To install poetry, following the official documentation, we should use the following command: https://python-poetry.org/docs/#installing-with-pipx ```shell pipx install poetry ``` Signed-off-by: Jérôme Benoit --- .github/actions/setup-python-build-env/action.yml | 5 ++--- .github/workflows/publish-to-pypi.yml | 1 - Makefile | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-python-build-env/action.yml b/.github/actions/setup-python-build-env/action.yml index 6b4101e02..1f4f16fd7 100644 --- a/.github/actions/setup-python-build-env/action.yml +++ b/.github/actions/setup-python-build-env/action.yml @@ -4,8 +4,7 @@ description: "Install everything needed to build" runs: using: "composite" steps: - - name: Upgrage pip and install poetry + - name: Install poetry shell: bash run: | - pip install --upgrade pip - pip install --user "poetry==1.5.1" + pipx install poetry diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 445d60943..1d4afa925 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -32,7 +32,6 @@ jobs: run: | proj_version=$(poetry version -s) if [ $proj_version != $TAG_VERSION ]; then echo "Version $proj_version, defined in pyproject.toml, does not match TAG $TAG_VERSION of this release"; exit 3; fi - poetry update poetry publish --build -u __token__ -p $PYPI_TOKEN env: TAG_VERSION: ${{ steps.context.outputs.TAG_VERSION }} diff --git a/Makefile b/Makefile index d41951ec8..01bc03c44 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ help: @echo " release version= bumps the project version to , using poetry;" @echo " Updates also docs/source/conf.py version;" @echo " If no version is provided, poetry outputs the current project version" - @echo " test run all the tests and linting" + @echo " tests run all the tests and linting" @echo " update updates the dependencies in poetry.lock" @echo "" @echo "Check the Makefile to know exactly what each target is doing." @@ -37,7 +37,7 @@ docs: .install-poetry poetry run sphinx-build -b html docs/source docs/build format: .install-poetry - poetry run isort ocpp tests && poetry run black ocpp tests + poetry run isort ocpp tests && poetry run black ocpp tests tests: .install-poetry poetry run black --check --diff ocpp tests From 447ebcbfd9223e8203093d65ce2e59977c5c29e4 Mon Sep 17 00:00:00 2001 From: Auke Willem Oosterhoff <1565144+OrangeTux@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:27:54 +0100 Subject: [PATCH 8/9] Finalize hand over to new maintainers. (#687) I just removed my access the project's Github and Pypi. Thanks for moving this project for forward @mdwcrft , @jainmohit2001 and @proelke . Good luck! @mdwcrft I didn't include your last name, since your Github profile doesn't expose that information. Let me know if you want to include that. cc: @Jared-Newell-Mobility --------- Co-authored-by: Mohit Jain <45727354+jainmohit2001@users.noreply.github.com> Co-authored-by: Chad <34003459+mdwcrft@users.noreply.github.com> --- README.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.rst b/README.rst index 9832ff545..291638691 100644 --- a/README.rst +++ b/README.rst @@ -203,6 +203,14 @@ To lower the logs for this package only use the following code: logging.getLogger('ocpp').setLevel(level=logging.DEBUG) logging.getLogger('ocpp').addHandler(logging.StreamHandler()) +Aknowledgements +--------------- + +Till the end of 2024, this project has been lead and maintained by `Auke Oosterhoff`_ and +`Jared Newell`_. We thank them for work their work! + +Since than, the project is lead by `Chad Meadowcroft`_, `Mohit Jain`_ and `Patrick Roelke`_. + License ------- @@ -217,3 +225,9 @@ Attribution-NoDerivatives 4.0 International Public License. .. _rtd: https://ocpp.readthedocs.io/en/latest/index.html .. _The Mobility House: https://www.mobilityhouse.com/int_en/ .. _websockets: https://pypi.org/project/websockets/ + +.. _Auke Oosterhoff: https://github.com/orangetux +.. _Jared Newell: https://github.com/Jared-Newell-Mobility +.. _Chad Meadowcroft: https://github.com/mdwcrft +.. _Mohit Jain: https://github.com/jainmohit2001 +.. _Patrick Roelke: https://github.com/proelke From cf21e4834a73a1d615cfe5c006fa839c43d6ad3c Mon Sep 17 00:00:00 2001 From: Andrew Mirsky Date: Mon, 9 Dec 2024 10:14:07 -0500 Subject: [PATCH 9/9] chore: Add code of conduct, contributing, security and support docs. (#681) Based on examples from other open-source repos in github: - code of conduct for those participating in the project - instructions for contributing to the project (including a pull request template to help facilitate) - how to report a security vulnerability - expectations of getting help with the project Contributes to https://github.com/mobilityhouse/ocpp/issues/671 --------- Co-authored-by: Mohit Jain <45727354+jainmohit2001@users.noreply.github.com> Co-authored-by: Chad <34003459+mdwcrft@users.noreply.github.com> --- .github/pull_request_template.md | 21 +++++++++ CODE_OF_CONDUCT.md | 74 ++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 43 +++++++++++++++++++ SECURITY.md | 33 ++++++++++++++ SUPPORT.md | 34 +++++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 .github/pull_request_template.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 SECURITY.md create mode 100644 SUPPORT.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..2e8477f4b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,21 @@ +### Changes included in this PR + +*(Bug fix, feature, docs update, ...)* + +### Current behavior + +*Link to an open issue here...* + +### New behavior + +*If this is a feature change, describe the new behavior* + +### Impact + +*Describe breaking changes, including changes a users might need to make due to this PR* + +### Checklist + +1. [ ] Does your submission pass the existing tests? +2. [ ] Are there new tests that cover these additions/changes? +3. [ ] Have you linted your code locally before submission? diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..86a391351 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at {{ email }}. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..0f46484ef --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,43 @@ +## Contributing + +[fork]: /fork +[pr]: /compare +[style]: https://standardjs.com/ +[code-of-conduct]: CODE_OF_CONDUCT.md + +Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great. + +Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms. + +## Issues and PRs + +If you have suggestions for how this project could be improved, or want to report a bug, open an issue! We'd love all and any contributions. If you have questions, too, we'd love to hear them. + +We'd also love PRs. If you're thinking of a large PR, we advise opening up an issue first to talk about it, though! Look at the links below if you're not sure how to open a PR. + +Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you. + +## Submitting a pull request + +1. [Fork][fork] and clone the repository. +2. Create a new branch: `git checkout -b my-branch-name`. +3. Configure and install the dependencies: `poetry install`. +4. Make sure the tests pass on your machine: `make install & make tests` +5. Make your change, add tests, and make sure the tests still pass. +6. Push to your fork and [submit a pull request][pr] and complete the information in the pull request template. + +## Linting requirements + +using `make install & make tests` will also run the following linters: + +- [Black: The uncompromising Python code formatter](https://black.readthedocs.io/en/stable/) +- [isort your imports, so you don't have to](https://pycqa.github.io/isort/) +- [flake8: Your Tool For Style Guide Enforcement](https://flake8.pycqa.org/en/latest/) + +using `make format` will run isort and black and apply any formatting suggestions from them + +## Resources + +- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) +- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/) +- [GitHub Help](https://help.github.com) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..cab277993 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,33 @@ +# Security Policy + +This document outlines security procedures and general policies for this OCPP project. + +## Supported Versions + +The currently supported versions of this OCPP project are: + +| Version | Supported | +|----------|--------------------| +| 2.0.0 | :soon: | +| 1.0.0 | :white_check_mark: | +| < 1.0.0 | :white_check_mark: | + +## Reporting a Vulnerability + +Please include the requested information listed below (as much as you can provide) to help +us better understand the nature and scope of the possible issue: + +- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) +- Full paths of source file(s) related to the manifestation of the issue +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- Step-by-step instructions to reproduce the issue +- Proof-of-concept or exploit code (if possible) +- Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +## Comments on this Policy + +If you have suggestions on how this process could be improved please submit a +pull request. Thanks! diff --git a/SUPPORT.md b/SUPPORT.md new file mode 100644 index 000000000..72b64a6c6 --- /dev/null +++ b/SUPPORT.md @@ -0,0 +1,34 @@ +# Support + +This article explains where to get help with this OCPP project. +Please read through the following guidelines. + +> 👉 **Note**: before participating in our community, please read our +> [code of conduct][coc]. +> By interacting with this repository, organization, or community you agree to +> abide by its terms. + +## Asking quality questions + +Questions can go to [GitHub discussions][chat]. + +Help us help you! +Spend time framing questions and add links and resources. +Spending the extra time up front can help save everyone time in the long run. +Here are some tips: + +* Search to find out if a similar question has been asked or a similar issue has been reported +* Check to see if a PR is already in progress for the issue you want to raise +* Try to define what you need help with: + * Is there something in particular you want to do? + * What problem are you encountering and what steps have you taken to try + and fix it? + * Is there a concept you don’t understand? +* Provide sample code, such as a [CodeSandbox][cs] or video, if possible +* Screenshots can help, but if there’s important text such as code or error + messages in them, please also provide those as text +* The more time you put into asking your question, the better we can help you + +## Contributions + +See [`contributing.md`][contributing] on how to contribute.