From 3f99eca37f20d23c7e5d59478d8f358289c4f7b6 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Thu, 6 Feb 2025 09:20:10 +0100 Subject: [PATCH] tox: fix lint target on python 3.13 Update all packages used in the lint target to their latest release. Explicitly bump the ubuntu image version in all GitHub action jobs. Fix errors reported by new pylint/black versions. Signed-off-by: Robin Jarry --- .github/workflows/ci.yml | 24 +++++++++++++++--------- Makefile | 5 ++--- libyang/schema.py | 4 +--- libyang/util.py | 2 ++ libyang/xpath.py | 2 +- pylintrc | 1 + tox.ini | 18 +++++++++--------- 7 files changed, 31 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48be6a11..a7797c88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,11 +3,17 @@ --- name: CI -on: [push, pull_request] +on: + pull_request: + branches: + - master + push: + branches: + - master jobs: lint: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -23,24 +29,24 @@ jobs: - run: python -m tox -e lint check-commits: - if: github.event_name == 'pull_request' + if: ${{ github.event.pull_request.commits }} runs-on: ubuntu-latest env: - LYPY_START_COMMIT: "${{ github.event.pull_request.base.sha }}" - LYPY_END_COMMIT: "${{ github.event.pull_request.head.sha }}" + LYPY_COMMIT_RANGE: "HEAD~${{ github.event.pull_request.commits }}.." steps: - run: sudo apt-get install git make - uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha || github.ref }} - run: make check-commits test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 strategy: matrix: include: - - python: 3.9 + - python: "3.9" toxenv: py39 - python: "3.10" toxenv: py310 @@ -56,7 +62,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python }} + python-version: "${{ matrix.python }}" - uses: actions/cache@v3 with: path: ~/.cache/pip @@ -86,7 +92,7 @@ jobs: deploy: needs: [lint, test] if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest + runs-on: ubuntu-24.03 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 diff --git a/Makefile b/Makefile index 6e9c436b..fc9a6ea3 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,9 @@ tests: format: tox -e format -LYPY_START_COMMIT ?= origin/master -LYPY_END_COMMIT ?= HEAD +LYPY_COMMIT_RANGE ?= origin/master.. check-commits: - ./check-commits.sh $(LYPY_START_COMMIT)..$(LYPY_END_COMMIT) + ./check-commits.sh $(LYPY_COMMIT_RANGE) .PHONY: lint tests format check-commits diff --git a/libyang/schema.py b/libyang/schema.py index 2e3a1154..3f3bd4d0 100644 --- a/libyang/schema.py +++ b/libyang/schema.py @@ -1542,9 +1542,7 @@ def defaults(self) -> Iterator[Union[None, bool, int, str, float]]: def max_elements(self) -> Optional[int]: return ( - self.cdata_leaflist.max - if self.cdata_leaflist.max != (2**32 - 1) - else None + self.cdata_leaflist.max if self.cdata_leaflist.max != (2**32 - 1) else None ) def min_elements(self) -> int: diff --git a/libyang/util.py b/libyang/util.py index d640a511..c380ae5e 100644 --- a/libyang/util.py +++ b/libyang/util.py @@ -121,4 +121,6 @@ def data_load(in_type, in_data, data, data_keepalive, encode=True): c_str = str2c(in_data, encode=encode) data_keepalive.append(c_str) ret = lib.ly_in_new_memory(c_str, data) + else: + raise ValueError("invalid input") return ret diff --git a/libyang/xpath.py b/libyang/xpath.py index ad5f2a58..e2a33196 100644 --- a/libyang/xpath.py +++ b/libyang/xpath.py @@ -85,7 +85,7 @@ def xpath_split(xpath: str) -> Iterator[Tuple[str, str, List[Tuple[str, str]]]]: # ------------------------------------------------------------------------------------- def _xpath_keys_to_key_name( - keys: List[Tuple[str, str]] + keys: List[Tuple[str, str]], ) -> Optional[Union[str, Tuple[str, ...]]]: """ Extract key name from parsed xpath keys returned by xpath_split. The return value diff --git a/pylintrc b/pylintrc index 16a9f0ae..acf27338 100644 --- a/pylintrc +++ b/pylintrc @@ -74,6 +74,7 @@ disable= too-many-branches, too-many-lines, too-many-locals, + too-many-positional-arguments, too-many-return-statements, too-many-statements, unused-argument, diff --git a/tox.ini b/tox.ini index b6b12c4c..524ad49c 100644 --- a/tox.ini +++ b/tox.ini @@ -36,8 +36,8 @@ basepython = python3 description = Format python code using isort and black. changedir = . deps = - black~=23.12.1 - isort~=5.13.2 + black~=25.1.0 + isort~=6.0.0 skip_install = true install_command = python3 -m pip install {opts} {packages} allowlist_externals = @@ -52,14 +52,14 @@ basepython = python3 description = Run coding style checks. changedir = . deps = - astroid~=3.0.2 - black~=23.12.1 - flake8~=7.0.0 - isort~=5.13.2 - pycodestyle~=2.11.1 + astroid~=3.3.8 + black~=25.1.0 + flake8~=7.1.1 + isort~=6.0.0 + pycodestyle~=2.12.1 pyflakes~=3.2.0 - pylint~=3.0.3 - setuptools~=69.0.3 + pylint~=3.3.4 + setuptools~=75.8.0 allowlist_externals = /bin/sh /usr/bin/sh