Skip to content
Merged
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
rev: v0.9.6
hooks:
- id: ruff
args:
Expand Down
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pytest >=7.0.1,<8.0.0
coverage[toml] >=6.2,<8.0
mypy ==1.4.1
ruff ==0.6.2
ruff ==0.9.6
# For FastAPI tests
fastapi >=0.103.2
httpx ==0.24.1
Expand Down
6 changes: 2 additions & 4 deletions sqlmodel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,15 @@ def __init__(self, default: Any = Undefined, **kwargs: Any) -> None:
)
if primary_key is not Undefined:
raise RuntimeError(
"Passing primary_key is not supported when "
"also passing a sa_column"
"Passing primary_key is not supported when also passing a sa_column"
)
if nullable is not Undefined:
raise RuntimeError(
"Passing nullable is not supported when also passing a sa_column"
)
if foreign_key is not Undefined:
raise RuntimeError(
"Passing foreign_key is not supported when "
"also passing a sa_column"
"Passing foreign_key is not supported when also passing a sa_column"
)
if ondelete is not Undefined:
raise RuntimeError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ def test_tutorial(clear_sqlmodel):
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero2_data["name"], "The name should not be set to none"
assert (
data["secret_name"] == "Spider-Youngster"
), "The secret name should be updated"
assert data["secret_name"] == "Spider-Youngster", (
"The secret name should be updated"
)

response = client.patch(f"/heroes/{hero3_id}", json={"age": None})
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero3_data["name"]
assert data["age"] is None, (
"A field should be updatable to None, even if " "that's the default"
"A field should be updatable to None, even if that's the default"
)

response = client.patch("/heroes/9001", json={"name": "Dragon Cube X"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ def test_tutorial(clear_sqlmodel):
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero2_data["name"], "The name should not be set to none"
assert (
data["secret_name"] == "Spider-Youngster"
), "The secret name should be updated"
assert data["secret_name"] == "Spider-Youngster", (
"The secret name should be updated"
)

response = client.patch(f"/heroes/{hero3_id}", json={"age": None})
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero3_data["name"]
assert data["age"] is None, (
"A field should be updatable to None, even if " "that's the default"
"A field should be updatable to None, even if that's the default"
)

response = client.patch("/heroes/9001", json={"name": "Dragon Cube X"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ def test_tutorial(clear_sqlmodel):
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero2_data["name"], "The name should not be set to none"
assert (
data["secret_name"] == "Spider-Youngster"
), "The secret name should be updated"
assert data["secret_name"] == "Spider-Youngster", (
"The secret name should be updated"
)

response = client.patch(f"/heroes/{hero3_id}", json={"age": None})
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero3_data["name"]
assert data["age"] is None, (
"A field should be updatable to None, even if " "that's the default"
"A field should be updatable to None, even if that's the default"
)

response = client.patch("/heroes/9001", json={"name": "Dragon Cube X"})
Expand Down
12 changes: 6 additions & 6 deletions tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def test_tutorial(clear_sqlmodel):
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero2_data["name"], "The name should not be set to none"
assert (
data["secret_name"] == "Spider-Youngster"
), "The secret name should be updated"
assert data["secret_name"] == "Spider-Youngster", (
"The secret name should be updated"
)
assert "password" not in data
assert "hashed_password" not in data
with Session(mod.engine) as session:
Expand All @@ -95,9 +95,9 @@ def test_tutorial(clear_sqlmodel):
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero3_data["name"]
assert (
data["age"] is None
), "A field should be updatable to None, even if that's the default"
assert data["age"] is None, (
"A field should be updatable to None, even if that's the default"
)
assert "password" not in data
assert "hashed_password" not in data
with Session(mod.engine) as session:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def test_tutorial(clear_sqlmodel):
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero2_data["name"], "The name should not be set to none"
assert (
data["secret_name"] == "Spider-Youngster"
), "The secret name should be updated"
assert data["secret_name"] == "Spider-Youngster", (
"The secret name should be updated"
)
assert "password" not in data
assert "hashed_password" not in data
with Session(mod.engine) as session:
Expand All @@ -98,9 +98,9 @@ def test_tutorial(clear_sqlmodel):
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero3_data["name"]
assert (
data["age"] is None
), "A field should be updatable to None, even if that's the default"
assert data["age"] is None, (
"A field should be updatable to None, even if that's the default"
)
assert "password" not in data
assert "hashed_password" not in data
with Session(mod.engine) as session:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def test_tutorial(clear_sqlmodel):
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero2_data["name"], "The name should not be set to none"
assert (
data["secret_name"] == "Spider-Youngster"
), "The secret name should be updated"
assert data["secret_name"] == "Spider-Youngster", (
"The secret name should be updated"
)
assert "password" not in data
assert "hashed_password" not in data
with Session(mod.engine) as session:
Expand All @@ -98,9 +98,9 @@ def test_tutorial(clear_sqlmodel):
data = response.json()
assert response.status_code == 200, response.text
assert data["name"] == hero3_data["name"]
assert (
data["age"] is None
), "A field should be updatable to None, even if that's the default"
assert data["age"] is None, (
"A field should be updatable to None, even if that's the default"
)
assert "password" not in data
assert "hashed_password" not in data
with Session(mod.engine) as session:
Expand Down