From ccc76a7ff67085fabb8b1dd71b671748d033dfd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 15 Oct 2026 16:52:25 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Enable=20Ruff=20formatting=20for?= =?UTF-8?q?=20Python=20in=20Markdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- docs/reference/parameters.md | 2 ++ docs/tutorial/commands/name.md | 6 ++---- docs/tutorial/index.md | 1 + docs/tutorial/package.md | 2 ++ docs/tutorial/parameter-types/file.md | 2 +- docs/tutorial/progressbar.md | 1 + pyproject.toml | 2 +- uv.lock | 4 ++-- 9 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3b5afedcf5..54ab578758 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-mypy name: mypy check diff --git a/docs/reference/parameters.md b/docs/reference/parameters.md index f73aa2f8b5..20960d2b46 100644 --- a/docs/reference/parameters.md +++ b/docs/reference/parameters.md @@ -8,6 +8,7 @@ import typer app = typer.Typer() + @app.command() def register( user: Annotated[str, typer.Argument()], @@ -18,6 +19,7 @@ def register( print(f"--age is {age}") print(f"--score is {score}") + if __name__ == "__main__": app() ``` diff --git a/docs/tutorial/commands/name.md b/docs/tutorial/commands/name.md index ac2bd4d35e..df9f92c268 100644 --- a/docs/tutorial/commands/name.md +++ b/docs/tutorial/commands/name.md @@ -5,8 +5,7 @@ By default, the command names are generated from the function name. So, if your function is something like: ```Python -def create(username: str): - ... +def create(username: str): ... ``` Then the command name will be `create`. @@ -50,7 +49,6 @@ Note that any underscores in the function name will be replaced with dashes. So if your function is something like: ```Python -def create_user(username: str): - ... +def create_user(username: str): ... ``` Then the command name will be `create-user`. diff --git a/docs/tutorial/index.md b/docs/tutorial/index.md index 0f70f29295..6d896d149d 100644 --- a/docs/tutorial/index.md +++ b/docs/tutorial/index.md @@ -17,6 +17,7 @@ In short (very short), you can declare a function with parameters like: ```Python from typing import Optional + def type_example(name: str, formal: bool = False, intro: Optional[str] = None): pass ``` diff --git a/docs/tutorial/package.md b/docs/tutorial/package.md index b238ebfe02..e8161d3ee0 100644 --- a/docs/tutorial/package.md +++ b/docs/tutorial/package.md @@ -200,6 +200,7 @@ The `app` in `"rick_portal_gun.main:app"` is the thing to import from the module ```Python from rick_portal_gun.main import app + app() ``` @@ -422,6 +423,7 @@ Then in that file you can execute your **Typer** program: ```Python from .main import app + app() ``` diff --git a/docs/tutorial/parameter-types/file.md b/docs/tutorial/parameter-types/file.md index 2f5c7aae38..1160714690 100644 --- a/docs/tutorial/parameter-types/file.md +++ b/docs/tutorial/parameter-types/file.md @@ -15,7 +15,7 @@ The difference is that these types will give you a Python [file-like object](htt A "file-like object" is the same type of object returned by `open()` as in: ```Python -with open('file.txt') as f: +with open("file.txt") as f: # Here f is the file-like object read_data = f.read() print(read_data) diff --git a/docs/tutorial/progressbar.md b/docs/tutorial/progressbar.md index ddedbffd4b..e481e32a83 100644 --- a/docs/tutorial/progressbar.md +++ b/docs/tutorial/progressbar.md @@ -189,6 +189,7 @@ def iterate_user_ids(): for i in range(100): yield i + for i in iterate_user_ids(): print(i) ``` diff --git a/pyproject.toml b/pyproject.toml index f4d0af0ebb..265e5e2732 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,7 +84,7 @@ tests = [ "pytest-sugar >=1.0.0", "pytest-xdist >=3.6.1", "rich >=12.3.0", - "ruff >=0.15.0", + "ruff >=0.16.0", "shellingham >=1.3.0", ] diff --git a/uv.lock b/uv.lock index 569fc831e3..1051050ba8 100644 --- a/uv.lock +++ b/uv.lock @@ -1887,7 +1887,7 @@ dev = [ { name = "pytest-xdist", specifier = ">=3.6.1" }, { name = "pyyaml", specifier = ">=5.3.1" }, { name = "rich", specifier = ">=12.3.0" }, - { name = "ruff", specifier = ">=0.15.0" }, + { name = "ruff", specifier = ">=0.16.0" }, { name = "shellingham", specifier = ">=1.3.0" }, { name = "ty", specifier = ">=0.0.25" }, { name = "zensical", specifier = ">=0.0.42" }, @@ -1919,7 +1919,7 @@ tests = [ { name = "pytest-sugar", specifier = ">=1.0.0" }, { name = "pytest-xdist", specifier = ">=3.6.1" }, { name = "rich", specifier = ">=12.3.0" }, - { name = "ruff", specifier = ">=0.15.0" }, + { name = "ruff", specifier = ">=0.16.0" }, { name = "shellingham", specifier = ">=1.3.0" }, { name = "ty", specifier = ">=0.0.25" }, ]