Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Oct 20, 2024
0 parents commit d19bc72
Show file tree
Hide file tree
Showing 18 changed files with 1,098 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: check

on: push

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python-version: "3.9"
usable-python-version: "3.9"
- python-version: "3.10"
usable-python-version: "3.10"
- python-version: "3.11"
usable-python-version: "3.11"
- python-version: "3.12"
usable-python-version: "3.12"
- python-version: "3.13"
usable-python-version: "3.13"
env:
# Configure a constant location for the uv cache
UV_CACHE_DIR: /tmp/.uv-cache

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: ./pw install

- name: Run tests
run: ./pw uv run pytest tests
- name: typecheck
run: ./pw uv run mypy
- name: lint
run: ./pw uv run pytest tests

- name: set minimum deps
run: ./pw uv pip install pydantic==2.4.2
- name: Run tests
run: ./pw uv run pytest tests
- name: typecheck
run: ./pw uv run mypy
- name: lint
run: ./pw uv run pytest tests

- name: Minimize uv cache
run: uv cache prune --ci
42 changes: 42 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: publish

on:
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest

env:
# Configure a constant location for the uv cache
UV_CACHE_DIR: /tmp/.uv-cache
python_version: "3.13"

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: $python_version

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- run: ./pw uv build
- run: ./pw uv publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

# Upload wheel as a release asset
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} ./dist/*

- name: Minimize uv cache
run: uv cache prune --ci
135 changes: 135 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

/.pyprojectx
11 changes: 11 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/pydantic-basedtyping.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions .idea/watcherTasks.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# pydantic-basedtyping

support for basedtyping features with pydantic:

```py
from pydantic import BaseModel

class A(BaseModel):
a: 1 | 2
A(a=1) # A(a=1)
A(a=2) # A(a=2)
A(a=3) # ValidationError
```

# installation

1. add `pydantic-basedtyping` as a dependency
2. install the plugin with:
```console
python -m pydantic_basedtyping install
```

this can be configured with pyprojectx:
```toml
[tool.pyprojectx]
install = "uv sync; uv run python -m pydantic_basedtyping install"
```
Loading

0 comments on commit d19bc72

Please sign in to comment.