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..4b24bd1bb3 100644 --- a/docs/db-to-code.md +++ b/docs/db-to-code.md @@ -132,9 +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: ") +# fmt: off session.exec( select(Hero).where(Hero.id == user_id) ).all() +# fmt: on ``` If the user provides this ID: @@ -231,9 +233,11 @@ results = database.execute(statement) But if you use common Python classes and objects, your editor will be able to help you: ```Python +# fmt: off database.execute( select(Hero).where(Hero.secret_name == "Dive Wilson") ).all() +# fmt: on ``` ![](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" },