Skip to content

Commit

Permalink
Migrate to Hatch build and mypy type checker
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed May 29, 2023
1 parent 4a4ef5a commit 2bf4279
Show file tree
Hide file tree
Showing 24 changed files with 322 additions and 200 deletions.
49 changes: 36 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ defaults:
run:
shell: bash
jobs:
build:
test:
strategy:
fail-fast: false
matrix:
include:
- python: '^3.9'
- python: '^3.10'
os: macos-latest
- python: 3.8
- python: '3.10'
os: windows-latest
- python: 3.9
os: ubuntu-latest
- python: 3.8
os: macos-latest
- python: 3.7
os: windows-latest
- python: 3.7
Expand All @@ -33,19 +37,38 @@ jobs:
- name: Pin to lowest versions
if: matrix.versions == 'minimal'
run: |
sed -i -E 's/"(\^|>=)([0-9])/"==\2/' pyproject.toml
- name: Setup virtualenv
uses: syphar/restore-virtualenv@d0a933d92488e0505e012c3367e3f987a6276f5a
sed -i -E 's/#min //; s/\b >=([0-9])/ ==\1/' pyproject.toml
- name: Install Hatch
run: |
pip install hatch
- name: Install dependencies
run: |
hatch run test:pip freeze
- name: Run tests
run: |
hatch run test:test
style:
runs-on: ubuntu-latest
steps:
- name: Download source
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
requirement_files: pyproject.toml
- name: Install packages
python-version: '3.10'
- name: Install Hatch
run: |
python -m pip install -U pip'>=19'; pip install -U wheel
pip install -U --upgrade-strategy=eager . $(awk '/^$/ {p = 0} ! /${{runner.os}}/ { if (p) {print $1} } /dev-dependencies/ {p = 1}' pyproject.toml)
- name: Test
pip install hatch
- name: Install dependencies
run: |
.tools/ci.sh with_groups
hatch run style:pip freeze
- name: Check formatting
if: matrix.versions == null
run: |
hatch run style:format
git diff --exit-code
- name: Install dependencies
run: |
hatch run types:pip freeze
- name: Check types
run: |
hatch run types:check
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
with:
python-version: '3.x'
- name: Install dependencies
run: pip install . -r docs/requirements.txt
run: pip install --no-deps -r docs/requirements.txt
- name: Build site
run: .tools/build_docs.sh
run: mkdocs build
- name: Deploy to gh-pages
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: oprypin/push-to-gh-pages@v3
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/dist/
site/
.pytype/
site*/
.mypy_cache/
.pytest_cache/
__pycache__/
*.egg-info/
Expand Down
16 changes: 0 additions & 16 deletions .tools/build_docs.sh

This file was deleted.

16 changes: 0 additions & 16 deletions .tools/ci.sh

This file was deleted.

13 changes: 0 additions & 13 deletions .tools/copier-answers.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .tools/docs-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e

hatch env show --json | jq -r ".docs.dependencies | .[]" | pip-compile -U - -o docs/requirements.txt
2 changes: 0 additions & 2 deletions .tools/hooks/pre-commit

This file was deleted.

12 changes: 6 additions & 6 deletions .tools/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ cd "$(dirname "$0")/.."

git diff --staged --quiet
git diff --quiet HEAD pyproject.toml
poetry version "$1"
poetry install
poetry build
git add pyproject.toml
rm -rf dist
hatch version "$1"
hatch build
git add mkdocstrings_handlers/crystal/__init__.py
git commit -m "v$1"
git tag -a -m "" "v$1"
poetry publish
echo git push origin master --tags
hatch publish
git push origin master --tags
7 changes: 0 additions & 7 deletions docs/requirements.in

This file was deleted.

65 changes: 38 additions & 27 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
#
# pip-compile docs/requirements.in
# pip-compile --output-file=docs/requirements.txt -
#
certifi==2023.5.7
# via requests
charset-normalizer==3.1.0
# via requests
click==8.1.3
# via mkdocs
colorama==0.4.6
# via
# griffe
# mkdocs-material
ghp-import==2.1.0
# via mkdocs
griffe==0.20.0
griffe==0.29.0
# via mkdocstrings-python
importlib-metadata==4.11.4
# via mkdocs
idna==3.4
# via requests
jinja2==3.1.2
# via
# mkdocs
Expand All @@ -25,57 +33,60 @@ markdown==3.3.7
# mkdocs-material
# mkdocstrings
# pymdown-extensions
markdown-callouts==0.2.0
# via -r docs/requirements.in
markupsafe==2.1.1
markdown-callouts==0.3.0
# via -r -
markupsafe==2.1.2
# via
# jinja2
# mkdocstrings
mergedeep==1.3.4
# via mkdocs
mkdocs==1.3.0
mkdocs==1.4.3
# via
# -r docs/requirements.in
# -r -
# mkdocs-autorefs
# mkdocs-material
# mkdocs-section-index
# mkdocstrings
mkdocs-autorefs==0.4.1
# via mkdocstrings
mkdocs-material==8.3.6
# via -r docs/requirements.in
mkdocs-material-extensions==1.0.3
mkdocs-material==9.1.14
# via -r -
mkdocs-material-extensions==1.1.1
# via mkdocs-material
mkdocs-section-index==0.3.4
# via -r docs/requirements.in
mkdocstrings==0.19.0
mkdocs-section-index==0.3.5
# via -r -
mkdocstrings==0.22.0
# via
# -r docs/requirements.in
# -r -
# mkdocstrings-python
mkdocstrings-python==0.7.1
# via -r docs/requirements.in
packaging==21.3
mkdocstrings-python==1.1.0
# via -r -
packaging==23.1
# via mkdocs
pygments==2.12.0
pygments==2.15.1
# via mkdocs-material
pymdown-extensions==9.5
pymdown-extensions==10.0.1
# via
# -r docs/requirements.in
# -r -
# mkdocs-material
# mkdocstrings
pyparsing==3.0.9
# via packaging
python-dateutil==2.8.2
# via ghp-import
pyyaml==6.0
# via
# mkdocs
# pymdown-extensions
# pyyaml-env-tag
pyyaml-env-tag==0.1
# via mkdocs
regex==2023.5.5
# via mkdocs-material
requests==2.31.0
# via mkdocs-material
six==1.16.0
# via python-dateutil
watchdog==2.1.9
urllib3==2.0.2
# via requests
watchdog==3.0.0
# via mkdocs
zipp==3.8.0
# via importlib-metadata
8 changes: 5 additions & 3 deletions mkdocstrings_handlers/crystal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
from .collector import CrystalCollector
from .renderer import CrystalRenderer

__version__ = "0.3.5"


class CrystalHandler(CrystalCollector, CrystalRenderer, BaseHandler):
load_inventory = staticmethod(inventory.list_object_urls)
load_inventory = staticmethod(inventory.list_object_urls) # type: ignore[assignment]

def __init__(
self,
theme: str,
custom_templates: Optional[str] = None,
crystal_docs_flags: Sequence[str] = (),
source_locations: Mapping[str, str] = {},
**config: Any
**config: Any,
) -> None:
BaseHandler.__init__(self, "crystal", theme, custom_templates)
BaseHandler.__init__(self, "crystal", theme, custom_templates) # type: ignore
CrystalCollector.__init__(
self, crystal_docs_flags=crystal_docs_flags, source_locations=source_locations
)
Expand Down
Loading

0 comments on commit 2bf4279

Please sign in to comment.