From f7b0cf21468163bef5769b7a4e43c98994ae6867 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Fri, 13 Nov 2026 15:42:23 +0100 Subject: [PATCH 1/4] ci: publish diraccfg to PyPI via trusted publisher --- .github/workflows/ci.yml | 44 +++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab92611..cfcc32c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,10 +42,14 @@ jobs: . "${CONDA}/bin/activate" test-env pylint -E src/diraccfg/ tests/ - publish-pypi: + build-pypi: runs-on: ubuntu-latest - name: Publish package to PyPI + name: Build package needs: [pytest, pre-commit] + outputs: + is-tag: ${{ steps.check-tag.outputs.is-tag }} + permissions: + contents: read steps: - uses: actions/checkout@v3 - run: | @@ -56,9 +60,35 @@ jobs: run: | . "${CONDA}/bin/activate" test-env python setup.py sdist bdist_wheel --universal - - name: Publish package - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master + - name: Check if this is a tag push + id: check-tag + env: + IS_TAG: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }} + run: echo "is-tag=$IS_TAG" >> "$GITHUB_OUTPUT" + - name: Upload the distribution packages + if: steps.check-tag.outputs.is-tag == 'true' + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: diraccfg-dist + path: dist/ + retention-days: 5 + + # Only this job talks to PyPI; the build above runs without any PyPI credential. + publish-pypi: + runs-on: ubuntu-latest + name: Publish package to PyPI + needs: build-pypi + if: needs.build-pypi.outputs.is-tag == 'true' && needs.build-pypi.result == 'success' + environment: pypi + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing on pypi + steps: + - name: Download the distribution packages + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: - user: __token__ - password: ${{ secrets.pypi_password }} + name: diraccfg-dist + path: dist/ + # Use trusted publisher for pypi + # https://docs.pypi.org/trusted-publishers/ + - name: Publish package + uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1 From 6fe70f96e496e4ac37149c7ff94cb7d57ac3b813 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Fri, 13 Nov 2026 17:01:40 +0100 Subject: [PATCH 2/4] fix: install conda in the CI jobs --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfcc32c..2cbb326 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,12 @@ jobs: - "3.11" steps: - uses: actions/checkout@v3 + - name: Install conda + run: | + wget -q -O /tmp/miniforge.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" + bash /tmp/miniforge.sh -b -p "${HOME}/miniforge" + echo "${HOME}/miniforge/bin" >> "$GITHUB_PATH" + echo "CONDA=${HOME}/miniforge" >> "$GITHUB_ENV" - name: Prepare environment run: .github/workflows/prepare_environment.sh ${{ matrix.python_version }} - name: Run pytest @@ -52,6 +58,12 @@ jobs: contents: read steps: - uses: actions/checkout@v3 + - name: Install conda + run: | + wget -q -O /tmp/miniforge.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" + bash /tmp/miniforge.sh -b -p "${HOME}/miniforge" + echo "${HOME}/miniforge/bin" >> "$GITHUB_PATH" + echo "CONDA=${HOME}/miniforge" >> "$GITHUB_ENV" - run: | git fetch --prune --unshallow - name: Prepare environment From 65a8126485e7e0d0601adc25e7974ad7a996f343 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Fri, 13 Nov 2026 22:21:09 +0100 Subject: [PATCH 3/4] fix: make the CI run on current runners and satisfy strict mypy --- .github/workflows/ci.yml | 2 +- src/diraccfg/cfg.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cbb326..18c709b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: '3.11' - name: Install pre-commit run: pip install pre-commit - name: Run pre-commit diff --git a/src/diraccfg/cfg.py b/src/diraccfg/cfg.py index 3fe6c19..88b2a63 100644 --- a/src/diraccfg/cfg.py +++ b/src/diraccfg/cfg.py @@ -642,7 +642,7 @@ def renameKey(self, oldName: str, newName: str) -> bool: return False # def __getitem__(self, key: str) -> CFG | str | Literal[False]: - def __getitem__(self, key: str) -> CFG | str: + def __getitem__(self, key: str) -> CFG | str | Literal[False]: """ Get the contents of a section/option @@ -653,7 +653,7 @@ def __getitem__(self, key: str) -> CFG | str: if key.find("/") > -1: subDict = self.getRecursive(key) if not subDict: - return False # type: ignore + return False # raise KeyError(key) return subDict["value"] return self.__dataDict[key] From 68d88b369b0291060d226c00955092ae203a0c42 Mon Sep 17 00:00:00 2001 From: aldbr <19813740+aldbr@users.noreply.github.com> Date: Tue, 17 Nov 2026 11:36:05 +0100 Subject: [PATCH 4/4] refactor: drop the commented-out __getitem__ signature It now duplicates the real signature. Assisted-by: Claude:claude-opus-5-5 --- src/diraccfg/cfg.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/diraccfg/cfg.py b/src/diraccfg/cfg.py index 88b2a63..4aa024e 100644 --- a/src/diraccfg/cfg.py +++ b/src/diraccfg/cfg.py @@ -641,7 +641,6 @@ def renameKey(self, oldName: str, newName: str) -> bool: else: return False - # def __getitem__(self, key: str) -> CFG | str | Literal[False]: def __getitem__(self, key: str) -> CFG | str | Literal[False]: """ Get the contents of a section/option