Skip to content

Commit d21554c

Browse files
authored
Merge branch 'main' into db-comments
2 parents 67bea0f + 3a8121f commit d21554c

Some content is hidden

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

62 files changed

+239
-243
lines changed

.github/DISCUSSION_TEMPLATE/questions.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ body:
6464
If I (or someone) can copy it, run it, and see it right away, there's a much higher chance I (or someone) will be able to help you.
6565
6666
placeholder: |
67-
from typing import Optional
68-
6967
from sqlmodel import Field, Session, SQLModel, create_engine
7068
7169
7270
class Hero(SQLModel, table=True):
73-
id: Optional[int] = Field(default=None, primary_key=True)
71+
id: int | None = Field(default=None, primary_key=True)
7472
name: str
7573
secret_name: str
76-
age: Optional[int] = None
74+
age: int | None = None
7775
7876
7977
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")

.github/workflows/build-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
with:
6060
python-version: "3.11"
6161
- name: Setup uv
62-
uses: astral-sh/setup-uv@v5
62+
uses: astral-sh/setup-uv@v6
6363
with:
6464
version: "0.4.15"
6565
enable-cache: true

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
with:
3030
python-version: "3.11"
3131
- name: Setup uv
32-
uses: astral-sh/setup-uv@v5
32+
uses: astral-sh/setup-uv@v6
3333
with:
3434
version: "0.4.15"
3535
enable-cache: true

.github/workflows/smokeshow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
python-version: '3.9'
2323
- name: Setup uv
24-
uses: astral-sh/setup-uv@v5
24+
uses: astral-sh/setup-uv@v6
2525
with:
2626
version: "0.4.15"
2727
enable-cache: true

.github/workflows/test.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,10 @@ jobs:
3232
- "3.10"
3333
- "3.11"
3434
- "3.12"
35+
- "3.13"
3536
pydantic-version:
3637
- pydantic-v1
3738
- pydantic-v2
38-
include:
39-
- os: ubuntu-22.04
40-
python-version: "3.7"
41-
pydantic-version: pydantic-v1
42-
- os: ubuntu-22.04
43-
python-version: "3.7"
44-
pydantic-version: pydantic-v2
4539
fail-fast: false
4640
runs-on: ${{ matrix.os }}
4741
steps:
@@ -51,7 +45,7 @@ jobs:
5145
with:
5246
python-version: ${{ matrix.python-version }}
5347
- name: Setup uv
54-
uses: astral-sh/setup-uv@v5
48+
uses: astral-sh/setup-uv@v6
5549
with:
5650
version: "0.4.15"
5751
enable-cache: true
@@ -71,10 +65,9 @@ jobs:
7165
run: uv pip install --upgrade "pydantic>=1.10.0,<2.0.0"
7266
- name: Install Pydantic v2
7367
if: matrix.pydantic-version == 'pydantic-v2'
74-
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0" "typing-extensions==4.6.1"
68+
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
7569
- name: Lint
76-
# Do not run on Python 3.7 as mypy behaves differently
77-
if: matrix.python-version != '3.7' && matrix.pydantic-version == 'pydantic-v2'
70+
if: matrix.pydantic-version == 'pydantic-v2' && matrix.python-version != '3.8'
7871
run: bash scripts/lint.sh
7972
- run: mkdir coverage
8073
- name: Test
@@ -97,9 +90,9 @@ jobs:
9790
- uses: actions/checkout@v4
9891
- uses: actions/setup-python@v5
9992
with:
100-
python-version: '3.12'
93+
python-version: '3.13'
10194
- name: Setup uv
102-
uses: astral-sh/setup-uv@v5
95+
uses: astral-sh/setup-uv@v6
10396
with:
10497
version: "0.4.15"
10598
enable-cache: true

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ default_language_version:
44
python: python3.10
55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.6.0
7+
rev: v5.0.0
88
hooks:
99
- id: check-added-large-files
1010
- id: check-toml
@@ -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.6.5
17+
rev: v0.11.6
1818
hooks:
1919
- id: ruff
2020
args:

README.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
<em>SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.</em>
77
</p>
88
<p align="center">
9-
<a href="https://github.com/fastapi/sqlmodel/actions?query=workflow%3ATest" target="_blank">
10-
<img src="https://github.com/fastapi/sqlmodel/workflows/Test/badge.svg" alt="Test">
9+
<a href="https://github.com/fastapi/sqlmodel/actions?query=workflow%3ATest+event%3Apush+branch%3Amain" target="_blank">
10+
<img src="https://github.com/fastapi/sqlmodel/actions/workflows/test.yml/badge.svg?event=push&branch=main" alt="Test">
1111
</a>
1212
<a href="https://github.com/fastapi/sqlmodel/actions?query=workflow%3APublish" target="_blank">
13-
<img src="https://github.com/fastapi/sqlmodel/workflows/Publish/badge.svg" alt="Publish">
13+
<img src="https://github.com/fastapi/sqlmodel/actions/workflows/publish.yml/badge.svg" alt="Publish">
1414
</a>
1515
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/sqlmodel" target="_blank">
1616
<img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/sqlmodel.svg" alt="Coverage">
@@ -105,16 +105,14 @@ And you want it to have this data:
105105
Then you could create a **SQLModel** model like this:
106106

107107
```Python
108-
from typing import Optional
109-
110108
from sqlmodel import Field, SQLModel
111109

112110

113111
class Hero(SQLModel, table=True):
114-
id: Optional[int] = Field(default=None, primary_key=True)
112+
id: int | None = Field(default=None, primary_key=True)
115113
name: str
116114
secret_name: str
117-
age: Optional[int] = None
115+
age: int | None = None
118116
```
119117

120118
That class `Hero` is a **SQLModel** model, the equivalent of a SQL table in Python code.
@@ -149,17 +147,15 @@ And **inline errors**:
149147

150148
You can learn a lot more about **SQLModel** by quickly following the **tutorial**, but if you need a taste right now of how to put all that together and save to the database, you can do this:
151149

152-
```Python hl_lines="18 21 23-27"
153-
from typing import Optional
154-
150+
```Python hl_lines="16 19 21-25"
155151
from sqlmodel import Field, Session, SQLModel, create_engine
156152

157153

158154
class Hero(SQLModel, table=True):
159-
id: Optional[int] = Field(default=None, primary_key=True)
155+
id: int | None = Field(default=None, primary_key=True)
160156
name: str
161157
secret_name: str
162-
age: Optional[int] = None
158+
age: int | None = None
163159

164160

165161
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
@@ -185,17 +181,15 @@ That will save a **SQLite** database with the 3 heroes.
185181

186182
Then you could write queries to select from that same database, for example with:
187183

188-
```Python hl_lines="15-18"
189-
from typing import Optional
190-
184+
```Python hl_lines="13-17"
191185
from sqlmodel import Field, Session, SQLModel, create_engine, select
192186

193187

194188
class Hero(SQLModel, table=True):
195-
id: Optional[int] = Field(default=None, primary_key=True)
189+
id: int | None = Field(default=None, primary_key=True)
196190
name: str
197191
secret_name: str
198-
age: Optional[int] = None
192+
age: int | None = None
199193

200194

201195
engine = create_engine("sqlite:///database.db")

docs/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ There is a script that you can run locally to test all the code and generate cov
6363
<div class="termy">
6464

6565
```console
66-
$ bash scripts/test-cov-html.sh
66+
$ bash scripts/test.sh
6767
```
6868

6969
</div>

docs/db-to-code.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ For example this class is part of that **Object** Oriented Programming:
252252

253253
```Python
254254
class Hero(SQLModel):
255-
id: Optional[int] = Field(default=None, primary_key=True)
255+
id: int | None = Field(default=None, primary_key=True)
256256
name: str
257257
secret_name: str
258-
age: Optional[int] = None
258+
age: int | None = None
259259
```
260260

261261
* **Relational**: refers to the **SQL Databases**. Remember that they are also called **Relational Databases**, because each of those tables is also called a "**relation**"? That's where the "**Relational**" comes from.
48.1 KB
Loading

0 commit comments

Comments
 (0)