diff --git a/.editorconfig b/.editorconfig index 51baf1204..6874683d6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,7 +9,7 @@ indent_size = 4 max_line_length = 120 # Same as .clang-format [*.py] -max_line_length = 88 # Same as Black +max_line_length = 88 # Same as Ruff's default [*.md] trim_trailing_whitespace = false diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 4816d046a..9309054aa 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -13,3 +13,6 @@ # 2024-05-28 formatted c++ source with clang-format 637448f8252ab142eedd539ddf9b08259b73eecc + +# 2024-10-14 formatted Python source with Ruff format +2b5191d8fc6f1d1fbde01481b49278c1957ef8f1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index edeb8e066..0cb4702dd 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,15 +3,18 @@ name: docs on: create: tags: - # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet + # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet - b[0-9][0-9][0-9] - publish-docs* push: branches: - main + pull_request: # Temporary just for test + branches: + - main jobs: - decompile: + generate: runs-on: windows-latest steps: @@ -22,44 +25,43 @@ jobs: with: python-version: '3.9' + # We still need to install pywin32 because + # AutoDuck/py2d.py currently relies on runtime imports for introspection + # Downloading latest release is faster than re-building - name: Install latest release run: pip install --user --upgrade pywin32 - - name: Set Python user site directory - run: python -c "import os,site;open(os.environ['GITHUB_ENV'], 'a').write(f'USER_DIR={site.USER_SITE}\n')" + - name: Generate PyWin32.chm help file + run: python AutoDuck/make.py - - name: Decompile shipped help file - run: hh -decompile site ${env:USER_DIR}\PyWin32.chm + - name: Decompile help file into HTML + run: hh -decompile site PyWin32.chm - name: Rename root HTML file run: mv site\PyWin32.HTML site\index.html - # Compress first to avoid slowly uploading thousands of individual files - - name: Create archive - run: python -m zipfile -c site.zip site - - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: documentation - path: site.zip + path: site/ publish: runs-on: ubuntu-latest needs: - - decompile + - generate # Only publish tags if: github.event_name == 'create' && github.event.ref_type == 'tag' steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: documentation - name: Unpack archive run: python -m zipfile -e site.zip . - - uses: peaceiris/actions-gh-pages@v3 + - uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: site diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2af0d70a0..1b004b1f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,6 +43,13 @@ jobs: run: | python setup.py install --user + # This needs to happen *after* installing pywin32 since + # AutoDuck/py2d.py currently relies on runtime imports for introspection + # This isn't included in the wheel (TODO: could we?) + # and only servces as a PR test for the docs.yaml workflow + - name: Generate PyWin32.chm help file + run: python AutoDuck/make.py + - name: Run tests # Run the tests directly from the source dir so support files (eg, .wav files etc) # can be found - they aren't installed into the Python tree. @@ -110,23 +117,22 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - # This job only needs to target the oldest version supported by our checkers - # (black>=24.10.0 supports Python >=3.9) - python-version: "3.9" + # This job only needs to target the oldest supported version + python-version: "3.8" cache: pip cache-dependency-path: .github/workflows/main.yml - run: pip install clang-format pycln - run: pycln . --config=pycln.toml --check - uses: astral-sh/ruff-action@v1 with: - version: "0.4.5" - - uses: psf/black@stable + version: "0.4.9" + - uses: astral-sh/ruff-action@v1 with: - options: "--fast --check --diff --verbose" + version: "0.4.9" + args: "format --check" - run: | # Too many files to fit in a single command, also exclude vendored Scintilla and MAPIStubLibrary clang-format --Werror --dry-run $(git ls-files '*.cpp') clang-format --Werror --dry-run $(git ls-files '*.h' ':!:Pythonwin/Scintilla/' ':!:com/win32comext/mapi/src/MAPIStubLibrary/') - shell: powershell mypy: runs-on: windows-2019 @@ -144,7 +150,7 @@ jobs: cache: pip cache-dependency-path: .github/workflows/main.yml check-latest: true - - run: pip install types-regex types-setuptools PyOpenGL mypy==1.11 + - run: pip install types-setuptools PyOpenGL mypy==1.11 - run: mypy . --python-version=${{ matrix.python-version }} pyright: @@ -163,7 +169,7 @@ jobs: cache-dependency-path: .github/workflows/main.yml check-latest: true # pyright vendors typeshed, but let's make sure we have the most up to date stubs - - run: pip install types-regex types-setuptools PyOpenGL + - run: pip install types-setuptools PyOpenGL - uses: jakebailey/pyright-action@v2 with: python-version: ${{ matrix.python-version }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a89a958b7..566983fae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,11 +29,7 @@ repos: hooks: - id: ruff # Run the linter. args: [--fix] - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.2 - hooks: - - id: black - verbose: true + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-clang-format rev: v18.1.5 hooks: diff --git a/AutoDuck/Dump2HHC.py b/AutoDuck/Dump2HHC.py index 343bdbca1..32c728c9d 100644 --- a/AutoDuck/Dump2HHC.py +++ b/AutoDuck/Dump2HHC.py @@ -293,9 +293,7 @@ def _genItemsFromDict(dict, cat, output, target, do_children=1): - """.format( - **locals() - ) + """.format(**locals()) ) if not do_children: continue @@ -339,9 +337,7 @@ def genTOC(cats, output, title, target):