From b70441f721c1063af510df40ff0ef71cb22b7a2a Mon Sep 17 00:00:00 2001 From: goingforstudying-ctrl Date: Thu, 21 May 2026 17:17:53 +0000 Subject: [PATCH] improve error message for methods argument in HTTP method decorators Clarify the TypeError raised when passing 'methods' to HTTP method decorators (get, post, etc.) by indicating which decorator was used and explicitly stating to use 'route' instead. --- src/flask/sansio/scaffold.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/flask/sansio/scaffold.py b/src/flask/sansio/scaffold.py index a04c38ad..75d16fd2 100644 --- a/src/flask/sansio/scaffold.py +++ b/src/flask/sansio/scaffold.py @@ -288,7 +288,10 @@ class Scaffold: options: dict[str, t.Any], ) -> t.Callable[[T_route], T_route]: if "methods" in options: - raise TypeError("Use the 'route' decorator to use the 'methods' argument.") + raise TypeError( + "The 'methods' argument is not allowed when using " + f"'{method.lower()}' decorator. Use the 'route' decorator instead." + ) return self.route(rule, methods=[method], **options)