APIFlask class-based view 报错: TypeError: view() takes 0 positional arguments but 1 was given

在example/cbv中, 使用/pets/{pet_id}时遇到如下错误

[2022-08-20 12:34:18,437] ERROR in app: Exception on /pets/1 [GET]
Traceback (most recent call last):
File “/Users/wukeying/Desktop/demos/apiflask/examples/venv/lib/python3.8/site-packages/flask/app.py”, line 2525, in wsgi_app
response = self.full_dispatch_request()
File “/Users/wukeying/Desktop/demos/apiflask/examples/venv/lib/python3.8/site-packages/flask/app.py”, line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/Users/wukeying/Desktop/demos/apiflask/examples/venv/lib/python3.8/site-packages/flask/app.py”, line 1820, in full_dispatch_request
rv = self.dispatch_request()
File “/Users/wukeying/Desktop/demos/apiflask/examples/venv/lib/python3.8/site-packages/apiflask/app.py”, line 428, in dispatch_request
return view_function(*req.view_args.values()) # type: ignore
TypeError: view() takes 0 positional arguments but 1 was given

1 Like

感谢反馈!这个是因为 Flask 2.2 的一处变动导致,临时可以 pin Flask 版本:

pip install flask==2.1

这几天会看看怎么处理这个问题。

相关 issue: