Mypy error when accessing flask.request.json
Closed this issue · 2 comments
skonstant commented
I use mypy to validate my project, I upgraded from flask 2 to flask 3 and now I see plenty of errors when I try to access the json property or flask.request
I just have a top level
import flask
Then:
j = flask.request.json # "Request" has no attribute "json"
Mypy: "Request" has no attribute "json" [attr-defined]
Environment:
- Python version: 3.13.0
- Flask version: 3.1.0
davidism commented
I can't reproduce this issue with the information provided. Creating a file with the given content does pass when running mypy --strict
.
DrLex0 commented
We found the actual problem; in case someone else bumps into this: we still had types-Werkzeug
in our requirements.txt, like types-Flask
it is outdated for Flask 3 and must be removed.