Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: website
on:
push:
branches:
- main
- docs/*
env:
COLUMNS: 150

jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4
- name: checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages

- uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: install
run: pip install uv

- name: checkout current branch
uses: actions/checkout@v4

- name: Set git credentials
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"

- run: uv run --extra doc mike deploy -b gh-pages dev --push
if: github.ref == 'refs/heads/main'

- if: startsWith(github.ref, 'refs/heads/docs')
id: check-version
uses: samuelcolvin/check-python-version@v4.1
with:
version_file_path: 'src/your_package_name/__about__.py'
skip_env_check: true

- run: uv run --extra doc mike deploy -b gh-pages ${{ steps.check-version.outputs.VERSION }} latest --update-aliases --push
if: startsWith(github.ref, 'refs/heads/docs') && !fromJSON(steps.check-version.outputs.IS_PRERELEASE)
env:
VERSION: v${{ steps.check-version.outputs.VERSION }}
27 changes: 27 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Mypy
on: [push]

jobs:
Static-Type-Checking:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install system packages
run: sudo apt-get install -y portaudio19-dev
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Type-checking package with mypy
run: |
uv run --all-extras mypy --strict .
30 changes: 0 additions & 30 deletions .github/workflows/pr-checks.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/tests.yml

This file was deleted.

19 changes: 10 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ repos:
hooks:
- id: prettier
types_or: [html]
- repo: https://github.com/psf/black
rev: 22.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.5
hooks:
- id: black
args: [--line-length=79]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", --line-length=72]
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
- repo: https://github.com/kynan/nbstripout
rev: 0.6.0
hooks:
Expand Down
11 changes: 11 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# What is this?

This is Python project template that I use for my projects.

## Features

1. `pyproject.toml` for managing dependencies and project metadata.
2. `mypy` for static type checking.
3. `pre-commit` for running code checks before committing.
4. `pytest` for running tests.
5. `mkdocs` for generating documentation.
100 changes: 100 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
site_name: Your Package Name
site_description: Your package description
strict: true
site_url: https://python_template.zhuhao.me
repo_url: https://github.com/ProKil/python_project_template
repo_name: Python Project Template

theme:
name: "material"
icon:
repo: fontawesome/brands/github
palette:
- media: "(prefers-color-scheme)"
scheme: default
primary: deep purple
accent: amber
toggle:
icon: material/lightbulb
name: "Switch to light mode"
- media: "(prefers-color-scheme: light)"
scheme: default
primary: deep purple
accent: amber
toggle:
icon: material/lightbulb-outline
name: "Switch to dark mode"
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: deep purple
accent: amber
toggle:
icon: material/lightbulb-auto-outline
name: "Switch to system preference"
features:
- content.tabs.link
- content.code.annotate
- content.code.copy
- announce.dismiss
- navigation.tabs
- navigation.instant
- navigation.instant.prefetch
- navigation.instant.preview
- navigation.instant.progress
- navigation.path
- navigation.sections
- navigation.top
- navigation.tracking
- search.suggest
- toc.follow

extra:
version:
provider: mike
analytics:
feedback:
title: Was this page helpful?
ratings:
- icon: material/thumb-up-outline
name: This page was helpful
data: 1
note: >-
Thanks for your feedback!
- icon: material/thumb-down-outline
name: This page could be improved
data: 0
note: >-
Thanks for your feedback!
nav:
- Get Started:
- What is this: index.md

plugins:
- social
- search
- mike:
alias_type: symlink
canonical_version: latest
- exclude:
glob:
- theme/announce.html
- plugins/*
- __pycache__/*
- mkdocstrings:
handlers:
python:
paths: [.]
options:
members_order: source
separate_signature: true
filters: ["!^_"]
docstring_options:
ignore_init_summary: true
merge_init_into_class: true
show_signature_annotations: true
signature_crossrefs: true
extensions:
- docs/plugins/griffe_doclinks.py
import:
- url: https://docs.python.org/3/objects.inv
domains: [py, std]
43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[project]
name = "your-package-name"
description = "Your package description"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"pydantic",
]
dynamic = ["version"]

[tool.hatch]
version = {path = "src/your_package_name/__about__.py"}

[project.optional-dependencies]
typing = [
"mypy",
]
doc = [
"mike",
"mkdocs-exclude",
"mkdocs-material[imaging]",
"mkdocstrings[python]",
"mkdocs-material[doc]>=9.5.43",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = [
"mypy",
"pytest"
]

[tool.mypy]
plugins = [
"pydantic.mypy",
"pydantic.v1.mypy",
]
exclude = [
"docs"
]
28 changes: 0 additions & 28 deletions setup.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

1 change: 1 addition & 0 deletions src/your_package_name/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
Empty file.
22 changes: 0 additions & 22 deletions stubs/gin/__init__.py

This file was deleted.

Loading