From 9c576c74db04754dd2907b7c7ef3f83bb29c3518 Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Fri, 19 Nov 2021 03:28:05 -0300 Subject: [PATCH] Fix typehints in route shorthand methods (#2317) * Fix typehints in route shorthand methods Change typehint of the version variable in RouteMixin to allow int string and float types values Resolves #2314 * fix lint error in version variable --- sanic/mixins/routes.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sanic/mixins/routes.py b/sanic/mixins/routes.py index 7139cd3c..a543a055 100644 --- a/sanic/mixins/routes.py +++ b/sanic/mixins/routes.py @@ -191,7 +191,7 @@ class RouteMixin: methods: Iterable[str] = frozenset({"GET"}), host: Optional[str] = None, strict_slashes: Optional[bool] = None, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, stream: bool = False, version_prefix: str = "/v", @@ -256,7 +256,7 @@ class RouteMixin: uri: str, host: Optional[str] = None, strict_slashes: Optional[bool] = None, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, ignore_body: bool = True, version_prefix: str = "/v", @@ -293,7 +293,7 @@ class RouteMixin: host: Optional[str] = None, strict_slashes: Optional[bool] = None, stream: bool = False, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, version_prefix: str = "/v", error_format: Optional[str] = None, @@ -329,7 +329,7 @@ class RouteMixin: host: Optional[str] = None, strict_slashes: Optional[bool] = None, stream: bool = False, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, version_prefix: str = "/v", error_format: Optional[str] = None, @@ -364,7 +364,7 @@ class RouteMixin: uri: str, host: Optional[str] = None, strict_slashes: Optional[bool] = None, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, ignore_body: bool = True, version_prefix: str = "/v", @@ -408,7 +408,7 @@ class RouteMixin: uri: str, host: Optional[str] = None, strict_slashes: Optional[bool] = None, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, ignore_body: bool = True, version_prefix: str = "/v", @@ -453,7 +453,7 @@ class RouteMixin: host: Optional[str] = None, strict_slashes: Optional[bool] = None, stream=False, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, version_prefix: str = "/v", error_format: Optional[str] = None, @@ -498,7 +498,7 @@ class RouteMixin: uri: str, host: Optional[str] = None, strict_slashes: Optional[bool] = None, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, ignore_body: bool = True, version_prefix: str = "/v", @@ -535,7 +535,7 @@ class RouteMixin: host: Optional[str] = None, strict_slashes: Optional[bool] = None, subprotocols: Optional[List[str]] = None, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, apply: bool = True, version_prefix: str = "/v", @@ -576,7 +576,7 @@ class RouteMixin: host: Optional[str] = None, strict_slashes: Optional[bool] = None, subprotocols=None, - version: Optional[int] = None, + version: Optional[Union[int, str, float]] = None, name: Optional[str] = None, version_prefix: str = "/v", error_format: Optional[str] = None,