From 236beb2a6d104796155e36c35df7d16b4d039a0d Mon Sep 17 00:00:00 2001 From: insolor <2442833+insolor@users.noreply.github.com> Date: Thu, 24 Jul 2025 00:01:07 +0300 Subject: [PATCH 1/2] Fix docstrings to be properly rendered by mkdocstrings-python Add annotations to *args and **kwags ruff format --- async_tkinter_loop/async_tkinter_loop.py | 17 ++++++----------- examples/custom_tkinter.py | 3 +-- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/async_tkinter_loop/async_tkinter_loop.py b/async_tkinter_loop/async_tkinter_loop.py index 2338212..bb545a4 100644 --- a/async_tkinter_loop/async_tkinter_loop.py +++ b/async_tkinter_loop/async_tkinter_loop.py @@ -14,9 +14,7 @@ async def main_loop(root: tk.Tk) -> None: code. Args: - ---- root: tkinter root window object - """ while True: # Process all pending events @@ -35,10 +33,8 @@ def get_event_loop() -> asyncio.AbstractEventLoop: """ A helper function which returns an event loop using current event loop policy. - Returns - ------- + Returns: event loop - """ return asyncio.get_event_loop_policy().get_event_loop() @@ -48,9 +44,7 @@ def async_mainloop(root: tk.Tk) -> None: A function, which is a substitute to the standard `root.mainloop()`. Args: - ---- root: tkinter root object - """ get_event_loop().run_until_complete(main_loop(root)) @@ -58,19 +52,21 @@ def async_mainloop(root: tk.Tk) -> None: P = ParamSpec("P") -def async_handler(async_function: Callable[P, Coroutine[Any, Any, None]], *args, **kwargs) -> Callable[P, None]: +def async_handler( + async_function: Callable[P, Coroutine[Any, Any, None]], + *args: Any, + **kwargs: Any, +) -> Callable[P, None]: """ A helper function which allows to use async functions as command handlers (e.g. button click handlers) or event handlers. Args: - ---- async_function: async function args: positional parameters which will be passed to the async function kwargs: keyword parameters which will be passed to the async function Returns: - ------- A sync function, which runs the original async function in an async event loop. Usage examples: @@ -105,7 +101,6 @@ async def some_async_function(): button = tk.Button("Press me", command=some_async_function) ``` - """ @wraps(async_function) diff --git a/examples/custom_tkinter.py b/examples/custom_tkinter.py index 6dd2473..bed886c 100644 --- a/examples/custom_tkinter.py +++ b/examples/custom_tkinter.py @@ -1,5 +1,4 @@ -"""A simple example how to use async code with CustomTkinter -""" +"""A simple example how to use async code with CustomTkinter""" import asyncio From ef3181e46fffb7f48162d6feae8f0067f839a2ee Mon Sep 17 00:00:00 2001 From: insolor <2442833+insolor@users.noreply.github.com> Date: Thu, 24 Jul 2025 00:05:34 +0300 Subject: [PATCH 2/2] Disable ANN401 checks on args and kwargs --- async_tkinter_loop/async_tkinter_loop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/async_tkinter_loop/async_tkinter_loop.py b/async_tkinter_loop/async_tkinter_loop.py index bb545a4..64d6a72 100644 --- a/async_tkinter_loop/async_tkinter_loop.py +++ b/async_tkinter_loop/async_tkinter_loop.py @@ -54,8 +54,8 @@ def async_mainloop(root: tk.Tk) -> None: def async_handler( async_function: Callable[P, Coroutine[Any, Any, None]], - *args: Any, - **kwargs: Any, + *args: Any, # noqa: ANN401 + **kwargs: Any, # noqa: ANN401 ) -> Callable[P, None]: """ A helper function which allows to use async functions as command handlers (e.g. button click handlers) or event