From 7d079ab7b4b6505934c01d8fee74183546e2fa87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 15 Oct 2026 16:52:24 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8E=A8=20Enable=20Ruff=20formatting?= =?UTF-8?q?=20for=20Python=20in=20Markdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- docs/db-to-code.md | 8 ++------ docs/tutorial/code-structure.md | 2 +- docs/tutorial/fastapi/update.md | 8 ++------ pyproject.toml | 2 +- uv.lock | 4 ++-- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5a5c5a379c..f1be2f21c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: entry: uv run ruff format --force-exclude --exit-non-zero-on-format require_serial: true language: unsupported - types: [python] + types_or: [python, markdown] - id: local-ty name: ty check diff --git a/docs/db-to-code.md b/docs/db-to-code.md index 24d09f8e6e..a4a127a43a 100644 --- a/docs/db-to-code.md +++ b/docs/db-to-code.md @@ -132,9 +132,7 @@ For example, you could ask the database for the same hero with ID `2` with this ```Python user_id = input("Type the user ID: ") -session.exec( - select(Hero).where(Hero.id == user_id) -).all() +session.exec(select(Hero).where(Hero.id == user_id)).all() ``` If the user provides this ID: @@ -231,9 +229,7 @@ results = database.execute(statement) But if you use common Python classes and objects, your editor will be able to help you: ```Python -database.execute( - select(Hero).where(Hero.secret_name == "Dive Wilson") -).all() +database.execute(select(Hero).where(Hero.secret_name == "Dive Wilson")).all() ``` ![](img/db-to-code/autocompletion01.png){class="shadow"} diff --git a/docs/tutorial/code-structure.md b/docs/tutorial/code-structure.md index 6db6217dd8..55b5b181fb 100644 --- a/docs/tutorial/code-structure.md +++ b/docs/tutorial/code-structure.md @@ -120,7 +120,7 @@ import project.app Then Python will execute that module *inside* of that package, and because Python is executing it directly, the same trick with the **main block** that we have in `app.py` will still work: ```Python -if __name__ == '__main__': +if __name__ == "__main__": main() ``` diff --git a/docs/tutorial/fastapi/update.md b/docs/tutorial/fastapi/update.md index e3c8ac6ac7..59baf1b5d5 100644 --- a/docs/tutorial/fastapi/update.md +++ b/docs/tutorial/fastapi/update.md @@ -87,9 +87,7 @@ But if the client sent a JSON with: Then the dictionary we would get in Python using `hero.model_dump(exclude_unset=True)` would be: ```Python -{ - "name": "Deadpuddle" -} +{"name": "Deadpuddle"} ``` Then we use that to get the data that was actually sent by the client: @@ -143,9 +141,7 @@ So, if the client wanted to intentionally remove the `age` of a hero, they could And when getting the data with `hero.model_dump(exclude_unset=True)`, we would get: ```Python -{ - "age": None -} +{"age": None} ``` So, we would use that value and update the `age` to `None` in the database, **just as the client intended**. diff --git a/pyproject.toml b/pyproject.toml index bdc4018932..6e32774796 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,7 +90,7 @@ tests = [ "psycopg[binary] >=3.2.10", "pymysql[rsa] >=1.1.1", "pytest >=7.0.1", - "ruff >=0.15.6", + "ruff >=0.16.0", "ty>=0.0.25", "typer >=0.26.1", "typing-extensions >=4.15.0", diff --git a/uv.lock b/uv.lock index 50d203f5e2..9295e6fc37 100644 --- a/uv.lock +++ b/uv.lock @@ -2014,7 +2014,7 @@ dev = [ { name = "pymysql", extras = ["rsa"], specifier = ">=1.1.1" }, { name = "pytest", specifier = ">=7.0.1" }, { name = "pyyaml", specifier = ">=5.3.1" }, - { name = "ruff", specifier = ">=0.15.6" }, + { name = "ruff", specifier = ">=0.16.0" }, { name = "sqlalchemy", extras = ["asyncio"] }, { name = "ty", specifier = ">=0.0.25" }, { name = "typer", specifier = ">=0.26.1" }, @@ -2054,7 +2054,7 @@ tests = [ { name = "psycopg", extras = ["binary"], specifier = ">=3.2.10" }, { name = "pymysql", extras = ["rsa"], specifier = ">=1.1.1" }, { name = "pytest", specifier = ">=7.0.1" }, - { name = "ruff", specifier = ">=0.15.6" }, + { name = "ruff", specifier = ">=0.16.0" }, { name = "sqlalchemy", extras = ["asyncio"] }, { name = "ty", specifier = ">=0.0.25" }, { name = "typer", specifier = ">=0.26.1" }, From 7be4a3def7131e0838d7aaed9535eab2c67367d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 15 Oct 2026 17:25:18 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9D=20Preserve=20multiline=20SQLMo?= =?UTF-8?q?del=20query=20examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/db-to-code.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/db-to-code.md b/docs/db-to-code.md index a4a127a43a..4b24bd1bb3 100644 --- a/docs/db-to-code.md +++ b/docs/db-to-code.md @@ -132,7 +132,11 @@ For example, you could ask the database for the same hero with ID `2` with this ```Python user_id = input("Type the user ID: ") -session.exec(select(Hero).where(Hero.id == user_id)).all() +# fmt: off +session.exec( + select(Hero).where(Hero.id == user_id) +).all() +# fmt: on ``` If the user provides this ID: @@ -229,7 +233,11 @@ results = database.execute(statement) But if you use common Python classes and objects, your editor will be able to help you: ```Python -database.execute(select(Hero).where(Hero.secret_name == "Dive Wilson")).all() +# fmt: off +database.execute( + select(Hero).where(Hero.secret_name == "Dive Wilson") +).all() +# fmt: on ``` ![](img/db-to-code/autocompletion01.png){class="shadow"}