Skip to content

Commit 202555a

Browse files
authored
Merge pull request #105 from lsst-sqre/u/jsickcodes/flask2
Update to Flask 2
2 parents 4e23e66 + 436a489 commit 202555a

File tree

11 files changed

+133
-667
lines changed

11 files changed

+133
-667
lines changed

CHANGELOG.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Change log
55
2.0.0 (Unreleased)
66
==================
77

8-
- Add support the testing mysql and postgres databases locally and in GitHub Actions.
8+
- Add support for testing mysql and postgres databases locally and in GitHub Actions.
9+
- Update to Flask 2.
910

1011
1.20.3 (2020-11-17)
1112
===================

Makefile

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ help:
1919
.PHONY: update-deps
2020
update-deps:
2121
pip install --upgrade pip-tools pip setuptools
22-
pip-compile --upgrade --build-isolation --generate-hashes --output-file requirements/main.txt requirements/main.in
23-
pip-compile --upgrade --build-isolation --generate-hashes --output-file requirements/dev.txt requirements/dev.in
22+
pip-compile --upgrade --build-isolation --output-file requirements/main.txt requirements/main.in
23+
pip-compile --upgrade --build-isolation --output-file requirements/dev.txt requirements/dev.in
2424

2525
.PHONY: init
2626
init:
27-
pip install --editable .
2827
pip install --upgrade -r requirements/main.txt -r requirements/dev.txt
28+
pip install --editable .
2929
rm -rf .tox
30-
pip install --upgrade pre-commit tox
31-
pip install --pre --upgrade tox-docker
30+
pip install --upgrade pre-commit tox tox-docker
3231
pre-commit install
3332

3433
.PHONY: update

keeper/api/dashboards.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import TYPE_CHECKING, Dict, Tuple
5+
from typing import Dict, Tuple
66

77
from flask_accept import accept_fallback
88

@@ -14,15 +14,12 @@
1414

1515
from ._models import QueuedResponse
1616

17-
if TYPE_CHECKING:
18-
from flask import Response
19-
2017

2118
@api.route("/dashboards", methods=["POST"])
2219
@accept_fallback
2320
@token_auth.login_required
2421
@permission_required(Permission.ADMIN_PRODUCT)
25-
def rebuild_all_dashboards() -> Tuple[Response, int, Dict[str, str]]:
22+
def rebuild_all_dashboards() -> Tuple[str, int, Dict[str, str]]:
2623
"""Rebuild the LTD Dasher dashboards for all products.
2724
2825
Note that dashboards are built asynchronously.

keeper/api/editions.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
from ._urls import build_from_url, url_for_edition
2727

2828
if TYPE_CHECKING:
29-
from flask import Response
30-
3129
from keeper.models import Build
3230

3331

@@ -207,7 +205,7 @@ def deprecate_edition(id: int) -> Tuple[str, int]:
207205
@api.route("/products/<slug>/editions/", methods=["GET"])
208206
@accept_fallback
209207
@log_route()
210-
def get_product_editions(slug: str) -> Response:
208+
def get_product_editions(slug: str) -> str:
211209
"""List all editions published for a Product.
212210
213211
**Example request**

keeper/api/queue.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Dict, Tuple
44

5-
from flask import abort, jsonify, url_for
5+
from flask import Response, abort, jsonify, url_for
66
from flask_accept import accept_fallback
77

88
from keeper.api import api
@@ -13,7 +13,7 @@
1313
@api.route("/queue/<id>", methods=["GET"])
1414
@accept_fallback
1515
@log_route()
16-
def get_task_status(id: int) -> Tuple[str, int, Dict[str, str]]:
16+
def get_task_status(id: int) -> Tuple[Response, int, Dict[str, str]]:
1717
try:
1818
if celery_app is not None:
1919
task = celery_app.AsyncResult(id)

keeper/appfactory.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def create_flask_app(profile: Optional[str] = None) -> Flask:
3232
config[_profile].init_app(app) # type: ignore # doesn't recog classmethod
3333

3434
# Add the middleware to respect headers forwarded from the proxy server
35+
# Assigning to the wsgi_app method is recommended by the Flask docs
3536
if app.config["PROXY_FIX"]:
36-
app.wsgi_app = ProxyFix(
37+
app.wsgi_app = ProxyFix( # type: ignore [assignment]
3738
app.wsgi_app,
3839
x_for=app.config["TRUST_X_FOR"],
3940
x_proto=app.config["TRUST_X_PROTO"],

keeper/v2api/tasks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from typing import Dict, Tuple
66

7-
from flask import abort, jsonify
7+
from flask import Response, abort, jsonify
88
from flask_accept import accept_fallback
99

1010
from keeper.auth import token_auth
@@ -19,7 +19,7 @@
1919
@accept_fallback
2020
@log_route()
2121
@token_auth.login_required
22-
def get_task(id: int) -> Tuple[str, int, Dict[str, str]]:
22+
def get_task(id: int) -> Tuple[Response, int, Dict[str, str]]:
2323
try:
2424
if celery_app is not None:
2525
task = celery_app.AsyncResult(id)

requirements/dev.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ sqlalchemy-stubs
1414
mock
1515
coverage[toml]
1616
mypy
17-
Sphinx<4
17+
Sphinx
1818
sphinx-rtd-theme
1919
numpydoc
2020
sphinxcontrib-httpdomain

requirements/dev.txt

+56-266
Large diffs are not rendered by default.

requirements/main.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# After editing, update requirements/main.txt by running:
66
# make update-deps
77

8-
Flask<2
8+
Flask
9+
itsdangerous<2.1
910
uWSGI
1011
Flask-SQLAlchemy
1112
SQLAlchemy

0 commit comments

Comments
 (0)