-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Flask version to 2.0.*, along with associated requirements #6154
Comments
A few things I thought of:
Dynamically adding attributes to the Flask object (or any object) is a bit of an anti-pattern as it causes various problems, one of them being that the dynamically-added attribute is not type-checked at all. Hence, in the context of type-checking, mypy is "right" to complain about it. I described this problem in more details in #5599. I am close to being done with the CryptoUtil refactoring to specifically address that (next PR at #6087, and after that one there will probably be one more). I think it would be valuable to remove dynamically-added attributes from the code base. After CryptoUtil, I think there will be a couple more (I remember Storage being one of them).
Similarly, using flask.g is a bit of anti-pattern too as it cannot be type-checked either (the content of g is fully dynamic). Overall, both patterns (dynamically adding attributes and using flask.g) are "incompatible" with type-checking (and have other problems). I think there's value in moving away from them. Not really what this GItHub issue is about but I thought I'd give my opinion 😅. |
Thanks @nabla-c0d3 - it may not explicitly be the topic of the issue but it does seem necessary for the version bump and is extremely useful feedback! Getting type checking working against CryptoUtil is probably the most critical part security-wise - thanks for the work you've done already. IIRC I'll take a look at #6087 on Monday and maybe also see about the requirements cleanup mentioned above (which isn't related to the code refactoring, but probably still needs doing). |
One gotcha here is that |
Description
Core requirements (Flask, Werkzeug, Jinja, etc) are lagging behind their most up-to-date available versions by quite a bit. This complicates the process of upgrading other requirements with shared dependencies (e.g. the
click
package).An attempt at updating these requirements to recent versions has been started in https://github.com/freedomofpress/securedrop/tree/add-https-to-dev - this has uncovered some juicy issues:
Pylint
now complains with anE0237: assgning-non-slot
error when attributes are assigned to the flask.g object - see Assigning to attribute flask.g.[...] not defined in class slots (assigning-non-slot) pallets/flask#4020 for more. (The simplest workaround for this is to disable pylint assigning-non-slot warnings, either selectively or globally)mypy
errors of note:error: "Flask" has no attribute "instance_config"
- see Mypy issue if assigning to AppContext or Flask pallets/flask#4167 for an explanationA more informed attempt would probably start by cleaning up the existing requirements so that the test requirements are in sync with securedrop-app-code requirements, and then address the mypy globals issue, since that is likely to have the biggest impact on application code.
Prerequisite tasks for this dependency update:
app.babel_instance
(done inadd-https-to-dev
branch)The text was updated successfully, but these errors were encountered: