diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8e4494..f5800d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,9 +14,9 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.0.0 + uses: actions/setup-python@v5 with: python-version: "3.10" - name: Install dependencies @@ -30,41 +30,34 @@ jobs: strategy: fail-fast: false matrix: - include: - - platform: ubuntu-latest - python-version: 3.8 - py: py38 - - platform: ubuntu-latest - python-version: 3.9 - py: py39 - - platform: ubuntu-latest - python-version: "3.10" - py: py310 - - platform: ubuntu-latest - python-version: "3.11" - py: py311 - - platform: macos-latest - python-version: 3.9 - py: py39 - - platform: macos-latest - python-version: "3.11" - py: py311 - - platform: windows-latest - python-version: 3.8 - py: py38 - - platform: windows-latest - python-version: "3.11" - py: py311 + py: + - 3.8 + - 3.9 + - "3.10" + - "3.11" + platform: + - ubuntu-latest + - macos-latest + - windows-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.0.0 + uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.py }} + - name: Pick environment to run + id: env + shell: python + run: | + import codecs, os, sys + env = f"py=py3{sys.version_info[1]}\n" + print(f"Picked {env.split('=')[1].strip()} for {sys.version}") + with codecs.open(os.environ["GITHUB_OUTPUT"], "a", "utf-8") as file_handler: + file_handler.write(env) - name: Install Hatch run: pip install -U hatch - name: Run tests - run: hatch run +py=${{ matrix.py }} tests:all + run: hatch run +py=${{ steps.env.outputs.py }} tests:all - name: Convert coverage to XML run: | pip install coverage covdefaults @@ -78,9 +71,9 @@ jobs: name: Build documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.0.0 + uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install dependencies @@ -89,7 +82,7 @@ jobs: run: hatch run docs:build env: SPHINX_GITHUB_CHANGELOG_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/upload-artifact@v4.0.0 + - uses: actions/upload-artifact@v4 with: path: docs/_build/html/* @@ -102,8 +95,8 @@ jobs: name: Build package runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 - - uses: actions/setup-python@v5.0.0 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 name: Setup Python with: python-version: "3.11" @@ -111,7 +104,7 @@ jobs: run: pip install -U hatch - name: Build package run: hatch build - - uses: actions/upload-artifact@v4.0.0 + - uses: actions/upload-artifact@v4 with: path: dist/* name: distribution @@ -121,7 +114,7 @@ jobs: needs: build-dist runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v4.1.0 + - uses: actions/download-artifact@v4 with: name: distribution path: dist @@ -137,7 +130,7 @@ jobs: needs: build-dist runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Get tag metadata id: tag run: | @@ -152,7 +145,7 @@ jobs: TAG_BODY="${TAG_BODY//$'\r'/'%0D'}" echo "body=$TAG_BODY" >> $GITHUB_OUTPUT - name: Create Release - uses: softprops/action-gh-release@v0.1.15 + uses: softprops/action-gh-release@v2 id: create-release with: name: ${{ steps.tag.outputs.title }} @@ -160,12 +153,12 @@ jobs: body: ${{ steps.tag.outputs.body }} draft: false prerelease: false - - uses: actions/download-artifact@v4.1.0 + - uses: actions/download-artifact@v4 name: Download builds with: name: distribution path: dist - - uses: shogo82148/actions-upload-release-asset@v1.7.2 + - uses: shogo82148/actions-upload-release-asset@v1 name: Upload release assets with: upload_url: ${{ steps.create-release.outputs.upload_url }} diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index e8e680f..8481f11 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -15,9 +15,9 @@ jobs: concurrency: group: ${{ github.workflow }}-${{ github.ref }} steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.0.0 + uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install dependencies @@ -30,7 +30,7 @@ jobs: id: get-version run: echo "version=$(cat pyproject.toml | grep "version = " -m 1 | cut -d' ' -f3 | cut -c 2- | rev | cut -c 2- | rev)" >> $GITHUB_OUTPUT - name: Deploy documentation - uses: peaceiris/actions-gh-pages@v3.9.3 + uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs/_build/html @@ -41,9 +41,9 @@ jobs: concurrency: group: ${{ github.workflow }}-${{ github.ref }} steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.0.0 + uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install dependencies @@ -53,7 +53,7 @@ jobs: env: SPHINX_GITHUB_CHANGELOG_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Deploy documentation - uses: peaceiris/actions-gh-pages@v3.9.3 + uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs/_build/html diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index 468087b..e419676 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -13,9 +13,9 @@ jobs: autoupdate: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.0.0 + uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install pre-commit @@ -23,7 +23,7 @@ jobs: - name: Run pre-commit autoupdate run: pre-commit autoupdate - name: Open pull request - uses: peter-evans/create-pull-request@v5.0.2 + uses: peter-evans/create-pull-request@v5 with: branch: pre-commit-autoupdate title: Upgrade pre-commit hooks revisions diff --git a/.github/workflows/update-copyright-years.yml b/.github/workflows/update-copyright-years.yml index 2c844df..f1cb681 100644 --- a/.github/workflows/update-copyright-years.yml +++ b/.github/workflows/update-copyright-years.yml @@ -13,9 +13,9 @@ jobs: update-license-year: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: FantasticFiasco/action-update-license-year@v3.0.2 + - uses: FantasticFiasco/action-update-license-year@v3 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-gh-actions.yml b/.github/workflows/update-gh-actions.yml index 13a1177..5116e45 100644 --- a/.github/workflows/update-gh-actions.yml +++ b/.github/workflows/update-gh-actions.yml @@ -9,7 +9,7 @@ jobs: update: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 with: token: ${{ secrets.UPDATE_GH_ACTIONS_TOKEN }} @@ -17,3 +17,4 @@ jobs: uses: saadmk11/github-actions-version-updater@v0.8.1 with: token: ${{ secrets.UPDATE_GH_ACTIONS_TOKEN }} + release_types: major diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0347720..08ec42e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: - id: check-useless-excludes name: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: trailing-whitespace name: trailing-whitespace @@ -40,7 +40,7 @@ repos: files: \.bat$ name: "*.bat end of lines" - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.0 + rev: v0.4.2 hooks: - id: ruff args: @@ -61,13 +61,13 @@ repos: name: editorconfig-checker alias: ec - repo: https://github.com/tcort/markdown-link-check - rev: v3.11.2 + rev: v3.12.1 hooks: - id: markdown-link-check name: markdown-link-check files: ^README\.md$ - repo: https://github.com/DavidAnson/markdownlint-cli2 - rev: v0.12.1 + rev: v0.13.0 hooks: - id: markdownlint-cli2 name: markdownlint-po2md-tests diff --git a/src/mdpo/md2po/__init__.py b/src/mdpo/md2po/__init__.py index aa8a793..9cd0f9a 100644 --- a/src/mdpo/md2po/__init__.py +++ b/src/mdpo/md2po/__init__.py @@ -870,10 +870,13 @@ def text(self, block, text): self.code_start_string, text, ) - 1 - self.current_msgid = '{}{}{}'.format( - self.current_msgid[:self._codespan_start_index], - self._codespan_backticks * self.code_start_string, - self.current_msgid[self._codespan_start_index:], + backticks = ( + self._codespan_backticks * self.code_start_string + ) + self.current_msgid = ( + f'{self.current_msgid[:self._codespan_start_index]}' + f'{backticks}' + f'{self.current_msgid[self._codespan_start_index:]}' ) if self._inside_aspan: self._current_aspan_text += text