Skip to content

Commit c8be602

Browse files
committed
initial
0 parents  commit c8be602

19 files changed

+1153
-0
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pw linguist-vendored
2+
pw.bat linguist-vendored
3+
pw.lock linguist-generated
4+
uv.lock linguist-generated

.github/workflows/check.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: check
2+
3+
on: push
4+
5+
env:
6+
# Configure a constant location for the uv cache
7+
UV_CACHE_DIR: /tmp/.uv-cache
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Restore uv cache
23+
uses: actions/cache@v4
24+
with:
25+
path: /tmp/.uv-cache
26+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
27+
restore-keys: |
28+
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
29+
uv-${{ runner.os }}
30+
31+
- name: Install the project
32+
run: ./pw install
33+
34+
- name: Install the project
35+
if: ${{ matrix.python-version == '3.13' }}
36+
run: ./pw install
37+
- name: lint
38+
if: ${{ matrix.python-version == '3.13' }}
39+
run: ./pw uv run ruff check --output-format github
40+
- name: format
41+
if: ${{ matrix.python-version == '3.13' }}
42+
run: ./pw uv run ruff format --check --diff
43+
44+
- name: Run tests
45+
run: ./pw uv run pytest tests
46+
- name: typecheck
47+
run: ./pw uv run mypy
48+
49+
- name: set minimum deps
50+
if: ${{ matrix.python-version != '3.13' }} # no wheels
51+
run: ./pw uv pip install pydantic==2.4.2
52+
- name: Run tests
53+
if: ${{ matrix.python-version != '3.13' }} # no wheels
54+
run: ./pw uv run pytest tests
55+
- name: typecheck
56+
if: ${{ matrix.python-version != '3.13' }} # no wheels
57+
run: ./pw uv run mypy
58+
59+
- name: Minimize uv cache
60+
run: ./pw uv cache prune --ci

.github/workflows/publish.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: publish
2+
3+
on:
4+
release:
5+
6+
jobs:
7+
check:
8+
runs-on: ubuntu-latest
9+
10+
env:
11+
# Configure a constant location for the uv cache
12+
UV_CACHE_DIR: /tmp/.uv-cache
13+
python_version: "3.13"
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: $python_version
20+
21+
- name: Restore px cache
22+
uses: actions/cache@v4
23+
with:
24+
path: .pyprojectx
25+
key: uv-${{ runner.os }}-3_13-${{ hashFiles('pw.lock') }}
26+
restore-keys: |
27+
px-${{ runner.os }}-3_13-${{ hashFiles('pw.lock') }}
28+
px-${{ runner.os }}
29+
30+
- name: Restore uv cache
31+
uses: actions/cache@v4
32+
with:
33+
path: /tmp/.uv-cache
34+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
35+
restore-keys: |
36+
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
37+
uv-${{ runner.os }}
38+
39+
- run: ./pw uv build
40+
- run: ./pw uv publish
41+
env:
42+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
43+
44+
# Upload wheel as a release asset
45+
- name: Upload Release Asset
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: gh release upload ${{ github.event.release.tag_name }} ./dist/*
49+
50+
- name: Minimize uv cache
51+
run: ./pw uv cache prune --ci

.gitignore

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
86+
__pypackages__/
87+
88+
# Celery stuff
89+
celerybeat-schedule
90+
celerybeat.pid
91+
92+
# SageMath parsed files
93+
*.sage.py
94+
95+
# Environments
96+
.env
97+
.venv
98+
env/
99+
venv/
100+
ENV/
101+
env.bak/
102+
venv.bak/
103+
104+
# Spyder project settings
105+
.spyderproject
106+
.spyproject
107+
108+
# Rope project settings
109+
.ropeproject
110+
111+
# mkdocs documentation
112+
/site
113+
114+
# mypy
115+
.mypy_cache/
116+
.dmypy.json
117+
dmypy.json
118+
119+
# Pyre type checker
120+
.pyre/
121+
122+
# pytype static type analyzer
123+
.pytype/
124+
125+
# Cython debug symbols
126+
cython_debug/
127+
128+
# PyCharm
129+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
130+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
131+
# and can be added to the global gitignore or merged into this file. For a more nuclear
132+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
133+
#.idea/
134+
135+
/.pyprojectx

.idea/.gitignore

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/pydantic-basedtyping.iml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/watcherTasks.xml

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# pydantic-basedtyping
2+
3+
support for basedtyping features with pydantic:
4+
5+
```py
6+
from __future__ import annotations
7+
8+
from pydantic import BaseModel
9+
10+
class A(BaseModel):
11+
a: 1 | 2
12+
A(a=1) # A(a=1)
13+
A(a=2) # A(a=2)
14+
A(a=3) # ValidationError
15+
```
16+
17+
> [!NOTE]
18+
> the types need to be written as a string, or `__future__.annotations` needs to be enabled
19+
20+
# installation
21+
22+
1. add `pydantic-basedtyping` as a dependency
23+
2. install the plugin with:
24+
```console
25+
python -m pydantic_basedtyping install
26+
```
27+
28+
if you are using [pyprojectx](https://pyprojectx.github.io/), this can be configured:
29+
```toml
30+
[tool.pyprojectx]
31+
install = ["uv sync", "uv run python -m pydantic_basedtyping install"]
32+
```

0 commit comments

Comments
 (0)