From 9fd83de059a9199827dfcfe4397051ec878cfea8 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sun, 20 Oct 2024 15:18:49 -0400 Subject: Update workflows, use ruff for linting, and drop EOL python versions --- .github/workflows/lint.yml | 25 + .github/workflows/python-package-ci.yml | 54 -- .github/workflows/python-publish.yml | 28 - .github/workflows/release.yml | 29 + .github/workflows/test.yml | 51 ++ CHANGELOG.rst | 6 +- lirc/client.py | 62 +- lirc/connection/abstract_connection.py | 3 +- lirc/connection/default_connection.py | 11 +- lirc/connection/lircd_connection.py | 23 +- lirc/exceptions.py | 9 +- lirc/reply_packet_parser.py | 42 +- poetry.lock | 1435 ++++++++++++------------------- pyproject.toml | 67 +- tests/test_client.py | 2 +- tests/test_lircd_connection.py | 4 +- 16 files changed, 765 insertions(+), 1086 deletions(-) create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/python-package-ci.yml delete mode 100644 .github/workflows/python-publish.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..ac32d61 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: Lint + +on: [push] + +jobs: + run-linters: + runs-on: ubuntu-22.04 + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Set up Poetry + run: pipx install poetry==1.8.4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.13 + cache: "poetry" + + - name: Install Dependencies + run: poetry install --only=dev --only=lint + + - name: Run linters + run: poetry run task lint diff --git a/.github/workflows/python-package-ci.yml b/.github/workflows/python-package-ci.yml deleted file mode 100644 index b3b884c..0000000 --- a/.github/workflows/python-package-ci.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: python package ci - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - versions: [ - {python: '3.6', poetry: '1.1.15'}, - {python: '3.7', poetry: '1.2.2'}, - {python: '3.8', poetry: '1.2.2'}, - {python: '3.9', poetry: '1.2.2'}, - {python: '3.10', poetry: '1.2.2'}, - {python: '3.11', poetry: '1.2.2'}, - {python: '3.12', poetry: '1.2.2'}, - {python: '3.13', poetry: '1.2.2'}, - ] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Poetry - run: pipx install poetry==${{ matrix.versions.poetry }} - - - name: Set up Python ${{ matrix.versions.python }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.versions.python }} - cache: 'poetry' - - - name: Install Dependencies - run: | - poetry install -v - poetry run pip install -r requirements-311.txt - - - name: Install system LIRC - run: sudo apt-get install lirc - - - name: Run tests - run: poetry run pytest -v tests/ --cov=lirc/ --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.xml - flags: unittests - name: codecov-umbrella - fail_ci_if_error: true - - - name: Build Package - run: poetry build diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index 94dbb24..0000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,28 +0,0 @@ -# This workflows will upload a Python Package using Poetry when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload Python Package - -on: - release: - types: [created] - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel poetry - - name: Build and publish - env: - PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - poetry publish --build -u $PYPI_USERNAME -p $PYPI_PASSWORD diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6a8ee37 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-22.04 + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel poetry + + - name: Build and publish + env: + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + poetry publish --build -u $PYPI_USERNAME -p $PYPI_PASSWORD diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..98c8fce --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,51 @@ +name: Test + +on: [push] + +jobs: + run-tests: + runs-on: ubuntu-22.04 + strategy: + matrix: + versions: + [ + { python: "3.9", poetry: "1.8.4" }, + { python: "3.10", poetry: "1.8.4" }, + { python: "3.11", poetry: "1.8.4" }, + { python: "3.12", poetry: "1.8.4" }, + { python: "3.13", poetry: "1.8.4" }, + ] + + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Set up Poetry + run: pipx install poetry==${{ matrix.versions.poetry }} + + - name: Set up Python ${{ matrix.versions.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.versions.python }} + cache: "poetry" + + - name: Install Dependencies + run: poetry install -v + + - name: Install system LIRC + run: sudo apt-get install lirc + + - name: Run tests + run: poetry run task + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml + flags: unittests + name: codecov-umbrella + fail_ci_if_error: true + + - name: Build Package + run: poetry build diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b934846..ffc286f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,7 +12,11 @@ Unreleased **Added** -- Official support for Python 3.12 and 3.13. +- Support for Python 3.12 and 3.13. + +**Removed** + +- Support for Python 3.6, 3.7, and 3.8. These versions are no longer supported by Python. 2.0.2 - 2022-11-25 ------------------ diff --git a/lirc/client.py b/lirc/client.py index 7b65457..80f514a 100644 --- a/lirc/client.py +++ b/lirc/client.py @@ -11,8 +11,7 @@ class Client: """Communicate with the lircd daemon.""" def __init__(self, connection: Type[AbstractConnection] = None) -> None: - """ - Initialize the client by connecting to the lircd socket. + """Initialize the client by connecting to the lircd socket. Args: connection: The connection to lircd. Created with defaults @@ -36,8 +35,7 @@ class Client: self._connection.connect() def _send_command(self, command: str) -> Union[str, List[str]]: - """ - Send a command to lircd. + """Send a command to lircd. Args: command: A command from the lircd socket command interface. @@ -66,8 +64,7 @@ class Client: self._connection.close() def send_once(self, remote: str, key: str, repeat_count: int = 0) -> None: - """ - Send an lircd SEND_ONCE command. + """Send an lircd SEND_ONCE command. Args: key: The name of the key to send. @@ -88,8 +85,7 @@ class Client: self._send_command(f"SEND_ONCE {remote} {key} {repeat_count}") def send_start(self, remote: str, key: str) -> None: - """ - Send an lircd SEND_START command. + """Send an lircd SEND_START command. This will repeat the given key until send_stop is called. @@ -106,8 +102,7 @@ class Client: self._send_command(f"SEND_START {remote} {key}") def send_stop(self, remote: str = "", key: str = "") -> None: - """ - Send an lircd SEND_STOP command. + """Send an lircd SEND_STOP command. The remote and key default to the remote and key last used with ``send_start`` if they are not specified, @@ -130,8 +125,7 @@ class Client: self._send_command(f"SEND_STOP {remote} {key}") def list_remotes(self) -> List[str]: - """ - List all the remotes that lirc has in + """List all the remotes that lirc has in its ``/etc/lirc/lircd.conf.d`` folder. Raises: @@ -143,8 +137,7 @@ class Client: return self._send_command("LIST") def list_remote_keys(self, remote: str) -> List[str]: - """ - List all the keys for a specific remote. + """List all the keys for a specific remote. Args: remote: The remote to list the keys of. @@ -158,8 +151,7 @@ class Client: return self._send_command(f"LIST {remote}") def start_logging(self, path: Union[str, Path]) -> None: - """ - Send a lircd SET_INPUTLOG command which sets + """Send a lircd SET_INPUTLOG command which sets the path to log all lircd received data to. Args: @@ -171,8 +163,7 @@ class Client: self._send_command(f"SET_INPUTLOG {path}") def stop_logging(self) -> None: - """ - Stop logging to the inputlog path from start_logging. + """Stop logging to the inputlog path from start_logging. Raises: LircdCommandFailure: If the command fails. @@ -182,8 +173,7 @@ class Client: self._send_command("SET_INPUTLOG") def version(self) -> str: - """ - Retrieve the version of LIRC + """Retrieve the version of LIRC Raises: LircdCommandFailure: If the command fails. @@ -194,8 +184,7 @@ class Client: return self._send_command("VERSION") def driver_option(self, key: str, value: str) -> None: - """ - Set driver-specific option named key to given value. + """Set driver-specific option named key to given value. Args: key: The key to set for the driver. @@ -207,10 +196,9 @@ class Client: self._send_command(f"DRV_OPTION {key} {value}") def simulate( - self, remote: str, key: str, repeat_count: int = 1, keycode: int = 0 + self, remote: str, key: str, repeat_count: int = 0, keycode: int = 0 ) -> None: - """ - Simulate an IR event. + """Simulate an IR event. The ``--allow-simulate`` command line option to lircd must be active for this command not to fail. @@ -218,8 +206,8 @@ class Client: Lircd Format: