{"record":{"id":"cb0032d0e6e1e61d","repo":"pallets/flask","slug":"use-the-route-decorator-to-use-the-methods-arg","errorCode":null,"errorMessage":"Use the 'route' decorator to use the 'methods' argument.","messagePattern":"Use the 'route' decorator to use the 'methods' argument\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/flask/sansio/scaffold.py","lineNumber":291,"sourceCode":"        \"\"\"The Jinja loader for this object's templates. By default this\n        is a class :class:`jinja2.loaders.FileSystemLoader` to\n        :attr:`template_folder` if it is set.\n\n        .. versionadded:: 0.5\n        \"\"\"\n        if self.template_folder is not None:\n            return FileSystemLoader(os.path.join(self.root_path, self.template_folder))\n        else:\n            return None\n\n    def _method_route(\n        self,\n        method: str,\n        rule: str,\n        options: dict[str, t.Any],\n    ) -> t.Callable[[T_route], T_route]:\n        if \"methods\" in options:\n            raise TypeError(\"Use the 'route' decorator to use the 'methods' argument.\")\n\n        return self.route(rule, methods=[method], **options)\n\n    @setupmethod\n    def get(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]:\n        \"\"\"Shortcut for :meth:`route` with ``methods=[\"GET\"]``.\n\n        .. versionadded:: 2.0\n        \"\"\"\n        return self._method_route(\"GET\", rule, options)\n\n    @setupmethod\n    def post(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]:\n        \"\"\"Shortcut for :meth:`route` with ``methods=[\"POST\"]``.\n\n        .. versionadded:: 2.0\n        \"\"\"\n        return self._method_route(\"POST\", rule, options)","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/pallets/flask/blob/3596b1ab61cea85edb8970e83ff61daa073facf8/src/flask/sansio/scaffold.py#L273-L309","documentation":"The HTTP-method shortcut decorators (get, post, put, delete, patch) route through _method_route, which hardcodes methods=[method]. Passing methods in options would be ambiguous/contradictory, so Flask raises TypeError and points the user to the generic route() decorator instead.","triggerScenarios":"Calling @app.get('/x', methods=['POST']); @app.post('/x', methods=['GET','POST']); passing methods= to any of get/post/put/delete/patch via kwargs.","commonSituations":"Copy-pasting options from an @app.route call onto a method shortcut; wanting to add HEAD/OPTIONS to a method shortcut; config-driven decorators merging options dicts that include methods.","solutions":["Use @app.route('/x', methods=[...]) when you need to control methods.","Remove the methods kwarg from the method shortcut call (the shortcut already implies the method).","If merging options programmatically, pop 'methods' before passing to the shortcut."],"exampleFix":"// before\n@app.get('/items', methods=['GET', 'HEAD'])\ndef items(): ...\n\n// after\n@app.route('/items', methods=['GET', 'HEAD'])\ndef items(): ...","handlingStrategy":"type-guard","validationCode":"def call_method_shortcut(decorator, rule, **options):\n    options.pop('methods', None)  # explicit guard\n    return decorator(rule, **options)\n","typeGuard":"def options_has_no_methods(options: dict) -> bool:\n    return 'methods' not in options\n","tryCatchPattern":null,"preventionTips":["Use @app.route(methods=[...]) when methods must be customized.","Do not forward a shared options dict into method shortcuts without popping methods.","Document shortcuts as 'no methods kwarg' in team conventions."],"tags":["flask","routing","type-error","methods","decorator"],"backgroundTag":null,"analyzedSha":"3596b1ab61cea85edb8970e83ff61daa073facf8","analyzedAt":"2026-08-11T20:11:52.622Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}