Skip to content

Commit

Permalink
refactor(api): Update type hints and docstrings for clarity and consi…
Browse files Browse the repository at this point in the history
…stency

Update type hints and docstrings across various modules to improve code readability and maintainability.

Signed-off-by: longhao <[email protected]>
  • Loading branch information
loonghao committed Dec 29, 2024
1 parent a3f7267 commit 8aa9c3c
Show file tree
Hide file tree
Showing 15 changed files with 505 additions and 2,178 deletions.
82 changes: 40 additions & 42 deletions .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
name: Deploy Documentation

on:
push:
branches: [ main ]
paths:
- 'docs/**'
- 'mkdocs.yml'
- '.github/workflows/publish_docs.yml'
- 'pyproject.toml'
- 'poetry.lock'
workflow_dispatch:

jobs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create false
poetry install --only docs
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Deploy documentation
run: |
mkdocs gh-deploy --force
name: Deploy Documentation

on:
push:
branches: [ main ]
paths:
- 'docs/**'
- 'mkdocs.yml'
- '.github/workflows/publish_docs.yml'
- 'pyproject.toml'
- 'poetry.lock'
workflow_dispatch:

jobs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nox
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Build and deploy documentation
run: |
nox -s docs
39 changes: 28 additions & 11 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,32 @@ jobs:
token: "${{ secrets.GITHUB_TOKEN }}"
fetch-depth: 0
ref: main

- uses: olegtarasov/[email protected]
id: get_tag_name
with:
tagRegex: "v(?<version>.*)"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install -U pip poetry mkdocs mkdocs-material
poetry --version
poetry build
# Note that we don't need credentials.
# We rely on https://docs.pypi.org/trusted-publishers/.
python -m pip install --upgrade pip
pip install nox build
- name: Build package
run: |
python -m build
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist

- name: Generate changelog
id: changelog
uses: jaywcjlove/changelog-generator@main
Expand All @@ -50,12 +57,22 @@ jobs:
{{fix}}
## Feature
{{feat}}
## Improve
{{refactor,perf,clean}}
## Misc
{{chore,style,ci||🔶 Nothing change}}
## Unknown
{{__unknown__}}
## Breaking Changes
{{breaking}}
## Updates
{{chore}}
## Document
{{docs}}
## Dependency
{{deps}}
## Style
{{style}}
## Test
{{test}}
## CI
{{ci}}
## Other
{{other}}
- uses: ncipollo/release-action@v1
with:
artifacts: "dist/*.whl"
Expand Down
21 changes: 6 additions & 15 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,13 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install -U pip poetry
poetry --version
poetry install
python -m pip install --upgrade pip
pip install nox
- name: Run tests and linters
- name: Run linting checks
run: |
#!/bin/sh -e
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
export PREFIX="poetry run python -m "
if [ -d 'venv' ] ; then
export PREFIX="venv/bin/"
fi
${PREFIX}black photoshop --check
${PREFIX}isort --check-only photoshop
${PREFIX}flake8 photoshop --max-line-length 120
nox -s pre-commit
14 changes: 3 additions & 11 deletions .github/workflows/test_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- '.github/workflows/test_docs.yml'
- 'pyproject.toml'
- 'poetry.lock'
- 'noxfile.py'

jobs:
test-docs:
Expand All @@ -30,17 +31,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry==${{ vars.POETRY_VERSION || '1.7.1' }}
poetry config virtualenvs.create false
poetry install --with docs
pip install nox
- name: Test documentation build
run: |
mkdocs build --strict
- name: Check for documentation warnings
run: |
if grep -r "WARNING" site/; then
echo "Documentation contains warnings"
exit 1
fi
nox -s docs-build
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
tests:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
os: [windows-latest]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nox
- name: Run tests
run: |
nox -s tests
Loading

0 comments on commit 8aa9c3c

Please sign in to comment.