From 1df72fd24be0403fec764673245d024aa4e8df37 Mon Sep 17 00:00:00 2001 From: raylu <90059+raylu@users.noreply.github.com> Date: Sun, 7 Apr 2024 18:44:55 -0700 Subject: [PATCH] add RouteDefinition in sample code this helps avoid https://github.com/python/mypy/issues/10740 --- docs/index.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index cd79261..eb5ff3c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,15 +7,19 @@ pigwig is a WSGI framework for python 3.6+:: #!/usr/bin/env python3 + import typing from pigwig import PigWig, Response + if typing.TYPE_CHECKING: + from pigwig import Request + from pigwig.routes import RouteDefinition - def root(request): + def root(request: Request) -> Response: return Response('hello, world!') - def shout(request, word): + def shout(request: Request, word: str) -> Response: return Response.json({'input': word, 'OUTPUT': word.upper()}) - routes = [ + routes: RouteDefinition = [ ('GET', '/', root), ('GET', '/shout/', shout), ]