Skip to content

Commit c08d129

Browse files
authored
Merge branch 'main' into dependabot/github_actions/actions/setup-python-5
2 parents f69deef + 32353ee commit c08d129

File tree

130 files changed

+9945
-618
lines changed

Some content is hidden

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

130 files changed

+9945
-618
lines changed

.flake8

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/build-docs.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ jobs:
2727
- README.md
2828
- docs/**
2929
- docs_src/**
30+
- requirements-docs.txt
3031
- pyproject.toml
3132
- mkdocs.yml
3233
- mkdocs.insiders.yml
33-
- ./github/workflows/build-docs.yml
34-
- ./github/workflows/deploy-docs.yml
34+
- .github/workflows/build-docs.yml
35+
- .github/workflows/deploy-docs.yml
3536
3637
build-docs:
3738
needs:
@@ -52,21 +53,16 @@ jobs:
5253
id: cache
5354
with:
5455
path: ${{ env.pythonLocation }}
55-
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01
56-
- name: Install Poetry
56+
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v01
57+
- name: Install docs extras
5758
if: steps.cache.outputs.cache-hit != 'true'
58-
run: |
59-
python -m pip install --upgrade pip
60-
python -m pip install "poetry"
61-
python -m poetry self add poetry-version-plugin
62-
- name: Configure poetry
63-
run: python -m poetry config virtualenvs.create false
64-
- name: Install Dependencies
65-
if: steps.cache.outputs.cache-hit != 'true'
66-
run: python -m poetry install
59+
run: pip install -r requirements-docs.txt
6760
- name: Install Material for MkDocs Insiders
6861
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true'
69-
run: python -m poetry run pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
62+
run: |
63+
pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
64+
pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git
65+
pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
7066
- uses: actions/cache@v3
7167
with:
7268
key: mkdocs-cards-${{ github.ref }}

.github/workflows/issue-manager.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
issue-manager:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: tiangolo/issue-manager@0.4.0
21+
- uses: tiangolo/issue-manager@0.4.1
2222
with:
2323
token: ${{ secrets.GITHUB_TOKEN }}
2424
config: >

.github/workflows/publish.yml

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,23 @@ on:
1414
jobs:
1515
publish:
1616
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
package:
20+
- sqlmodel
21+
permissions:
22+
id-token: write
1723
steps:
1824
- uses: actions/checkout@v4
1925
- name: Set up Python
2026
uses: actions/setup-python@v5
2127
with:
22-
python-version: "3.7"
23-
# Allow debugging with tmate
24-
- name: Setup tmate session
25-
uses: mxschmitt/action-tmate@v3
26-
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
27-
with:
28-
limit-access-to-actor: true
29-
- uses: actions/cache@v3
30-
id: cache
31-
with:
32-
path: ${{ env.pythonLocation }}
33-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2
34-
- name: Install poetry
35-
if: steps.cache.outputs.cache-hit != 'true'
36-
run: |
37-
python -m pip install --upgrade pip
38-
python -m pip install "poetry"
39-
python -m poetry self add poetry-version-plugin
40-
- name: Configure poetry
41-
run: python -m poetry config virtualenvs.create false
42-
- name: Install Dependencies
43-
if: steps.cache.outputs.cache-hit != 'true'
44-
run: python -m poetry install
45-
- name: Publish
28+
python-version: "3.11"
29+
- name: Install build dependencies
30+
run: pip install build
31+
- name: Build distribution
4632
env:
47-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
48-
run: |
49-
python -m poetry config pypi-token.pypi $PYPI_TOKEN
50-
bash scripts/publish.sh
33+
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
34+
run: python -m build
35+
- name: Publish
36+
uses: pypa/gh-action-pypi-publish@v1.8.11
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test Redistribute
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
12+
jobs:
13+
test-redistribute:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
package:
18+
- sqlmodel
19+
steps:
20+
- name: Dump GitHub context
21+
env:
22+
GITHUB_CONTEXT: ${{ toJson(github) }}
23+
run: echo "$GITHUB_CONTEXT"
24+
- uses: actions/checkout@v4
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.10"
29+
- name: Install build dependencies
30+
run: pip install build
31+
- name: Build source distribution
32+
env:
33+
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
34+
run: python -m build --sdist
35+
- name: Decompress source distribution
36+
run: |
37+
cd dist
38+
tar xvf sqlmodel*.tar.gz
39+
- name: Install test dependencies
40+
run: |
41+
cd dist/sqlmodel*/
42+
pip install -r requirements-tests.txt
43+
- name: Run source distribution tests
44+
run: |
45+
cd dist/sqlmodel*/
46+
bash scripts/test.sh
47+
- name: Build wheel distribution
48+
run: |
49+
cd dist
50+
pip wheel --no-deps sqlmodel*.tar.gz

.github/workflows/test.yml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
1515
required: false
1616
default: 'false'
17+
schedule:
18+
# cron every week on monday
19+
- cron: "0 0 * * 1"
1720

1821
jobs:
1922
test:
@@ -48,31 +51,23 @@ jobs:
4851
id: cache
4952
with:
5053
path: ${{ env.pythonLocation }}
51-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2
52-
- name: Install poetry
53-
if: steps.cache.outputs.cache-hit != 'true'
54-
run: |
55-
python -m pip install --upgrade pip
56-
python -m pip install "poetry"
57-
python -m poetry self add poetry-version-plugin
58-
- name: Configure poetry
59-
run: python -m poetry config virtualenvs.create false
54+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}
6055
- name: Install Dependencies
6156
if: steps.cache.outputs.cache-hit != 'true'
62-
run: python -m poetry install
57+
run: pip install -r requirements-tests.txt
6358
- name: Install Pydantic v1
6459
if: matrix.pydantic-version == 'pydantic-v1'
65-
run: pip install "pydantic>=1.10.0,<2.0.0"
60+
run: pip install --upgrade "pydantic>=1.10.0,<2.0.0"
6661
- name: Install Pydantic v2
6762
if: matrix.pydantic-version == 'pydantic-v2'
68-
run: pip install "pydantic>=2.0.2,<3.0.0"
63+
run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
6964
- name: Lint
7065
# Do not run on Python 3.7 as mypy behaves differently
7166
if: matrix.python-version != '3.7' && matrix.pydantic-version == 'pydantic-v2'
72-
run: python -m poetry run bash scripts/lint.sh
67+
run: bash scripts/lint.sh
7368
- run: mkdir coverage
7469
- name: Test
75-
run: python -m poetry run bash scripts/test.sh
70+
run: bash scripts/test.sh
7671
env:
7772
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
7873
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.1.6
17+
rev: v0.2.0
1818
hooks:
1919
- id: ruff
2020
args:

docs/advanced/decimal.md

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,44 @@ For the database, **SQLModel** will use <a href="https://docs.sqlalchemy.org/en/
3333

3434
Let's say that each hero in the database will have an amount of money. We could make that field a `Decimal` type using the `condecimal()` function:
3535

36-
```{.python .annotate hl_lines="12" }
36+
//// tab | Python 3.10+
37+
38+
```python hl_lines="11"
39+
{!./docs_src/advanced/decimal/tutorial001_py310.py[ln:1-11]!}
40+
41+
# More code here later 👇
42+
```
43+
44+
////
45+
46+
//// tab | Python 3.7+
47+
48+
```python hl_lines="12"
3749
{!./docs_src/advanced/decimal/tutorial001.py[ln:1-12]!}
3850

3951
# More code here later 👇
4052
```
4153

54+
////
55+
4256
/// details | 👀 Full file preview
4357

58+
//// tab | Python 3.10+
59+
60+
```Python
61+
{!./docs_src/advanced/decimal/tutorial001_py310.py!}
62+
```
63+
64+
////
65+
66+
//// tab | Python 3.7+
67+
4468
```Python
4569
{!./docs_src/advanced/decimal/tutorial001.py!}
4670
```
4771

72+
////
73+
4874
///
4975

5076
Here we are saying that `money` can have at most `5` digits with `max_digits`, **this includes the integers** (to the left of the decimal dot) **and the decimals** (to the right of the decimal dot).
@@ -63,11 +89,11 @@ We are also saying that the number of decimal places (to the right of the decima
6389
🚫 But these are all invalid numbers for that `money` field:
6490

6591
* `1.2345`
66-
* This number has more than 3 decimal places.
92+
* This number has more than 3 decimal places.
6793
* `123.234`
68-
* This number has more than 5 digits in total (integer and decimal part).
94+
* This number has more than 5 digits in total (integer and decimal part).
6995
* `123`
70-
* Even though this number doesn't have any decimals, we still have 3 places saved for them, which means that we can **only use 2 places** for the **integer part**, and this number has 3 integer digits. So, the allowed number of integer digits is `max_digits` - `decimal_places` = 2.
96+
* Even though this number doesn't have any decimals, we still have 3 places saved for them, which means that we can **only use 2 places** for the **integer part**, and this number has 3 integer digits. So, the allowed number of integer digits is `max_digits` - `decimal_places` = 2.
7197

7298
/// tip
7399

@@ -79,6 +105,20 @@ Make sure you adjust the number of digits and decimal places for your own needs,
79105

80106
When creating new models you can actually pass normal (`float`) numbers, Pydantic will automatically convert them to `Decimal` types, and **SQLModel** will store them as `Decimal` types in the database (using SQLAlchemy).
81107

108+
//// tab | Python 3.10+
109+
110+
```Python hl_lines="4-6"
111+
# Code above omitted 👆
112+
113+
{!./docs_src/advanced/decimal/tutorial001_py310.py[ln:24-34]!}
114+
115+
# Code below omitted 👇
116+
```
117+
118+
////
119+
120+
//// tab | Python 3.7+
121+
82122
```Python hl_lines="4-6"
83123
# Code above omitted 👆
84124

@@ -87,18 +127,46 @@ When creating new models you can actually pass normal (`float`) numbers, Pydanti
87127
# Code below omitted 👇
88128
```
89129

130+
////
131+
90132
/// details | 👀 Full file preview
91133

134+
//// tab | Python 3.10+
135+
136+
```Python
137+
{!./docs_src/advanced/decimal/tutorial001_py310.py!}
138+
```
139+
140+
////
141+
142+
//// tab | Python 3.7+
143+
92144
```Python
93145
{!./docs_src/advanced/decimal/tutorial001.py!}
94146
```
95147

148+
////
149+
96150
///
97151

98152
## Select Decimal data
99153

100154
Then, when working with Decimal types, you can confirm that they indeed avoid those rounding errors from floats:
101155

156+
//// tab | Python 3.10+
157+
158+
```Python hl_lines="15-16"
159+
# Code above omitted 👆
160+
161+
{!./docs_src/advanced/decimal/tutorial001_py310.py[ln:37-50]!}
162+
163+
# Code below omitted 👇
164+
```
165+
166+
////
167+
168+
//// tab | Python 3.7+
169+
102170
```Python hl_lines="15-16"
103171
# Code above omitted 👆
104172

@@ -107,12 +175,26 @@ Then, when working with Decimal types, you can confirm that they indeed avoid th
107175
# Code below omitted 👇
108176
```
109177

178+
////
179+
110180
/// details | 👀 Full file preview
111181

182+
//// tab | Python 3.10+
183+
184+
```Python
185+
{!./docs_src/advanced/decimal/tutorial001_py310.py!}
186+
```
187+
188+
////
189+
190+
//// tab | Python 3.7+
191+
112192
```Python
113193
{!./docs_src/advanced/decimal/tutorial001.py!}
114194
```
115195

196+
////
197+
116198
///
117199

118200
## Review the results
3.9 KB
Loading

0 commit comments

Comments
 (0)