From f01776a23fe0f4d4047fee6c99f608e4344ce6ae Mon Sep 17 00:00:00 2001 From: OlegZv <19969581+OlegZv@users.noreply.github.com> Date: Thu, 29 May 2025 20:59:09 -0400 Subject: [PATCH 1/4] remove 3.7 from the matrix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 580d47c..a46186e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13] + python-version: [3.8, 3.9, 3.10, 3.11, 3.12, 3.13] steps: - name: Checkout code From cf3da2e224ce6fe62f9a418f5bd54e65157ef1af Mon Sep 17 00:00:00 2001 From: OlegZv <19969581+OlegZv@users.noreply.github.com> Date: Thu, 29 May 2025 21:02:52 -0400 Subject: [PATCH 2/4] fix 3.10 version and add 3.8 compatibility --- .github/workflows/test.yml | 4 ++-- python_cayennelpp/decoder.py | 4 ++-- python_cayennelpp/methods.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a46186e..d3eff0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Code Quality Checks +name: Lint/Test on: push: @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, 3.10, 3.11, 3.12, 3.13] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout code diff --git a/python_cayennelpp/decoder.py b/python_cayennelpp/decoder.py index e96eb4a..95e3535 100644 --- a/python_cayennelpp/decoder.py +++ b/python_cayennelpp/decoder.py @@ -1,7 +1,7 @@ """Main decoder for CayenneLPP payload format.""" import logging -from typing import Any +from typing import Any, Dict, List from python_cayennelpp.methods import hex_library logger = logging.getLogger(__name__) @@ -26,7 +26,7 @@ def decode(payload: str): ) # parsing payload using hex_library. # variable pointer represents caret in line to cut. result is returned result - result: list[dict[str, Any]] = [] + result: List[Dict[str, Any]] = [] pointer = 0 try: while pointer < len(payload): diff --git a/python_cayennelpp/methods.py b/python_cayennelpp/methods.py index d31c11c..ed5053f 100644 --- a/python_cayennelpp/methods.py +++ b/python_cayennelpp/methods.py @@ -1,6 +1,6 @@ """This module contains methods to decode CayenneLPP sensor data.""" -from typing import Any +from typing import Any, Dict def hex_to_int(hex_string: str, signed: bool = True): @@ -114,7 +114,7 @@ def gps_location(data: str): } -hex_library: dict[str, dict[str, Any]] = { +hex_library: Dict[str, Dict[str, Any]] = { "00": { "name": "Digital Input", "size": 2, From dbfb7aec200cdd8ff0bed593b2599cda3a9a0ab2 Mon Sep 17 00:00:00 2001 From: OlegZv <19969581+OlegZv@users.noreply.github.com> Date: Fri, 30 May 2025 18:37:13 -0400 Subject: [PATCH 3/4] Add release publishing action --- .github/workflows/release.yml | 37 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 2 +- README.md | 3 +++ pyproject.toml | 5 +++++ python_cayennelpp/__init__.py | 1 + 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d5b8c18 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release to PyPI + +on: + release: + types: + - published + +jobs: + publish-to-pypi: + runs-on: ubuntu-latest + permissions: + id-token: write + + + steps: + # Checkout the repository + - name: Checkout code + uses: actions/checkout@v4 + + # Set up Python + - name: Setup uv + uses: astral-sh/setup-uv@v6 + with: + version: "0.7.8" + enable-cache: true + cache-dependency-glob: | + pyproject.toml + + - name: Build package distributions + run: uv build + + # Publish to PyPI + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3eff0d..65b83d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -59,7 +59,7 @@ jobs: - name: Run pytest run: uv run python -m pytest --cov=python_cayennelpp tests/ --cov-report=xml - - name: Code ./coverage1.xml + - name: Code Coverage uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index ea5a245..84d34c9 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Open-source library for python to decode CayenneLPP format payload. The Cayenne Low Power Payload (LPP) provides a convenient and easy way to send data over LPWAN networks such as LoRaWAN. More details on CayenneLPP payload: https://github.com/myDevicesIoT/cayenne-docs +> Note: while Python versions 2.7 and <=3.7 may work, they're not officially supported since they're EOL. + ## Installation To install the package use next pip command @@ -23,6 +25,7 @@ To decode payload simply use method decode() from this package >>>print(decode('03670110056700FF')) [{'channel': 3, 'name': 'Temperature Sensor', 'value': 27.2}, {'channel': 5, 'name': 'Temperature Sensor', 'value': 25.5}] ``` + ## Additional info The package may raise following exceptions: - `TypeError` - if the provided data is not of the `str` type diff --git a/pyproject.toml b/pyproject.toml index d5afc13..fe5a10e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,3 +42,8 @@ dev = [ "ruff>=0.11.12", ] +[[tool.uv.index]] +name = "testpypi" +url = "https://test.pypi.org/simple/" +publish-url = "https://test.pypi.org/legacy/" +explicit = true \ No newline at end of file diff --git a/python_cayennelpp/__init__.py b/python_cayennelpp/__init__.py index b4ed04a..b173efd 100644 --- a/python_cayennelpp/__init__.py +++ b/python_cayennelpp/__init__.py @@ -1 +1,2 @@ """Python CayenneLPP decoder library.""" +__version__ = "0.0.5" \ No newline at end of file From 50d1c260f78a4c3fbb97088e36758885dd1d904e Mon Sep 17 00:00:00 2001 From: OlegZv <19969581+OlegZv@users.noreply.github.com> Date: Fri, 30 May 2025 18:38:23 -0400 Subject: [PATCH 4/4] Add newlines --- pyproject.toml | 2 +- python_cayennelpp/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fe5a10e..c5deded 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,4 +46,4 @@ dev = [ name = "testpypi" url = "https://test.pypi.org/simple/" publish-url = "https://test.pypi.org/legacy/" -explicit = true \ No newline at end of file +explicit = true diff --git a/python_cayennelpp/__init__.py b/python_cayennelpp/__init__.py index b173efd..a7de90e 100644 --- a/python_cayennelpp/__init__.py +++ b/python_cayennelpp/__init__.py @@ -1,2 +1,3 @@ """Python CayenneLPP decoder library.""" -__version__ = "0.0.5" \ No newline at end of file + +__version__ = "0.0.5"