Skip to content

Commit 36df393

Browse files
committed
Initial
0 parents  commit 36df393

57 files changed

Lines changed: 1993 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
3+
name: CI tasks
4+
5+
on:
6+
pull_request: {}
7+
push:
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
tests:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-latest, macos-latest]
22+
python-version: ["3.12", "3.13"]
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Display Python version
31+
run: python -c "import sys; print(sys.version)"
32+
33+
- name: Install venv
34+
run: ./tools/uv sync --locked
35+
36+
- name: Run tests
37+
shell: bash
38+
run: ./tools/ci tests -v

.github/workflows/lint.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
3+
name: Lint
4+
5+
on:
6+
pull_request: {}
7+
push:
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.13"
25+
26+
- name: Install venv
27+
run: ./tools/uv sync --locked
28+
29+
- name: Ensure linter is happy
30+
run: ./tools/ci lint
31+
32+
types:
33+
runs-on: ubuntu-latest
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
python-version: ["3.12", "3.13"]
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Set up Python
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: ${{ matrix.python-version }}
45+
46+
- name: Install venv
47+
run: ./tools/uv sync --locked
48+
49+
- name: Ensure mypy is happy
50+
run: ./tools/ci types
51+
52+
format:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Set up Python
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: "3.13"
61+
62+
- name: Install venv
63+
run: ./tools/uv sync --locked
64+
65+
- name: Ensure code is formatted
66+
run: |
67+
./tools/ci format
68+
69+
git status --porcelain
70+
71+
# Complain if there were changes
72+
if [[ ! -z "$(git status --porcelain)" ]]; then
73+
echo "=========================================="
74+
echo "Found changes!"
75+
echo "Please run ./format before committing code"
76+
echo "=========================================="
77+
git diff
78+
exit 1
79+
fi

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
on:
2+
- workflow_dispatch
3+
4+
name: Release Packages
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
build:
11+
name: Create the package
12+
runs-on: ubuntu-latest
13+
environment: github_release
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.13"
20+
21+
- id: build
22+
run: ./tools/uv build
23+
24+
- id: version
25+
run: |
26+
version=$(python -c "import runpy; print(runpy.run_path('django_consistency_enforcer/version.py')['VERSION'])")
27+
versiondash=$(python -c "import runpy; print(runpy.run_path('django_consistency_enforcer/version.py')['VERSION'].replace('.', '-'))")
28+
29+
echo "version=$version" >> $GITHUB_OUTPUT
30+
echo "versiondash=$versiondash" >> $GITHUB_OUTPUT
31+
32+
- id: create-release
33+
uses: softprops/action-gh-release@v2
34+
with:
35+
name: django_consistency_enforcer ${{ steps.version.outputs.version }}
36+
body: "https://django-consistency-enforcer-mypy-django-plugin.readthedocs.io/en/latest/api/changelog.html#release-${{ steps.version.outputs.versiondash }}"
37+
tag_name: "release-${{ steps.version.outputs.version }}"
38+
fail_on_unmatched_files: true
39+
draft: false
40+
prerelease: false
41+
files: "dist/*"
42+
43+
- uses: pypa/gh-action-pypi-publish@v1.12.4
44+
with:
45+
user: __token__
46+
password: ${{ secrets.PYPI_API_TOKEN_CORE }}
47+
packages_dir: dist

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.egg-info/
2+
.venv/
3+
.dmypy.json
4+
__pycache__/
5+
*.pyc
6+
.tox/
7+
dist/
8+
pip-wheel-metadata/
9+
.mypy_django_scratch

.readthedocs.advice.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
3+
build:
4+
os: ubuntu-22.04
5+
tools:
6+
python: "3.12"
7+
8+
sphinx:
9+
configuration: docs/advice/conf.py
10+
11+
python:
12+
install:
13+
- requirements: ./tools/.requirements.readthedocs.txt
14+
- method: pip
15+
path: .

.readthedocs.project.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
3+
build:
4+
os: ubuntu-22.04
5+
tools:
6+
python: "3.12"
7+
8+
sphinx:
9+
configuration: docs/project/conf.py
10+
11+
python:
12+
install:
13+
- requirements: ./tools/.requirements.readthedocs.txt
14+
- method: pip
15+
path: .

DEVELOPMENT.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Development
2+
===========
3+
4+
This project uses `uv` to manage a ``virtualenv``.
5+
6+
All the commands will only install things locally to this repository.
7+
8+
To run mypy against this code::
9+
10+
> ./types
11+
12+
To clear the cache first::
13+
14+
> CLEAR_MYPY_CACHE=1 ./types
15+
16+
To run tests::
17+
18+
> ./test.sh
19+
20+
To run tests such that breakpoints work::
21+
22+
> ./test.sh --mypy-same-process -s
23+
24+
To activate the ``virtualenv`` in your current shell::
25+
26+
> source dev activate
27+
28+
To build the docs locally::
29+
30+
> ./dev docs view

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2025 Kraken
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
22+

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Static typing advice and django consistency enforcer
2+
====================================================
3+
4+
https://django-consistency_enforcer.readthedocs.io
5+
6+
https://kraken-static-typing-advice.readthedocs.io

dev

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
# https://stackoverflow.com/questions/2683279/how-to-detect-if-a-script-is-being-sourced
4+
sourced=0
5+
if [ -n "$ZSH_VERSION" ]; then
6+
case $ZSH_EVAL_CONTEXT in *:file) sourced=1;; esac
7+
elif [ -n "$KSH_VERSION" ]; then
8+
# shellcheck disable=SC2296
9+
[ "$(cd -- "$(dirname -- "$0")" && pwd -P)/$(basename -- "$0")" != "$(cd -- "$(dirname -- "${.sh.file}")" && pwd -P)/$(basename -- "${.sh.file}")" ] && sourced=1
10+
elif [ -n "$BASH_VERSION" ]; then
11+
(return 0 2>/dev/null) && sourced=1
12+
else
13+
# All other shells: examine $0 for known shell binary filenames.
14+
# Detects `sh` and `dash`; add additional shell filenames as needed.
15+
case ${0##*/} in sh|-sh|dash|-dash)
16+
if [ -z "$PROJECT_ROOT" ]; then
17+
echo "POSIX environments need PROJECT_ROOT in the environment for 'source run.sh activate' to work"
18+
echo "This must be set to the root of this repository"
19+
return 1
20+
fi
21+
;;
22+
esac
23+
fi
24+
25+
# Bash does not make it easy to find where this file is
26+
# Here I'm making it so it doesn't matter what directory you are in
27+
# when you execute this script. And it doesn't matter whether you're
28+
# executing a symlink to this script
29+
# Note the `-h` in the while loop asks if this path is a symlink
30+
pushd . >'/dev/null'
31+
DIRECTORY_BEFORE="$(pwd)"
32+
SCRIPT_PATH="${BASH_SOURCE[0]:-$0}"
33+
34+
find_here() {
35+
while [ -h "$SCRIPT_PATH" ]; do
36+
cd "$(dirname -- "$SCRIPT_PATH")" || return 1
37+
SCRIPT_PATH="$(readlink -f -- "$SCRIPT_PATH")"
38+
done
39+
cd "$(dirname -- "$SCRIPT_PATH")" >'/dev/null' || return 1
40+
}
41+
42+
if ! find_here; then
43+
if [ "$sourced" = "1" ]; then
44+
return 1
45+
else
46+
exit 1
47+
fi
48+
fi
49+
50+
PROJECT_ROOT=$(pwd)
51+
export PROJECT_ROOT
52+
53+
if ! ./tools/uv sync --locked -q; then
54+
if [ "$sourced" = "1" ]; then
55+
return 1
56+
else
57+
exit 1
58+
fi
59+
fi
60+
61+
if [ -f ./tools/requirements.local.txt ]; then
62+
if ! ./tools/uv pip install -q -r ./tools/requirements.local.txt; then
63+
if [ "$sourced" = "1" ]; then
64+
return 1
65+
else
66+
exit 1
67+
fi
68+
fi
69+
fi
70+
71+
if [ "$sourced" = "1" ]; then
72+
# shellcheck source=/dev/null
73+
source .venv/bin/activate
74+
cd "$DIRECTORY_BEFORE" || return 1
75+
else
76+
exec ./tools/uv run ./tools/run.py "$@"
77+
fi

0 commit comments

Comments
 (0)