lots of typing fixes
This commit is contained in:
parent
51f580a304
commit
3665c34961
43 changed files with 260 additions and 178 deletions
|
@ -1,7 +1,9 @@
|
|||
import json
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from flask import render_template, url_for, flash, redirect, Blueprint, Response
|
||||
from flask.typing import ResponseReturnValue
|
||||
from flask_wtf import FlaskForm
|
||||
from sqlalchemy import exc
|
||||
from wtforms import SelectField, StringField, SubmitField
|
||||
|
@ -28,7 +30,7 @@ def list_format_name(s: str) -> str:
|
|||
|
||||
|
||||
@bp.route('/list')
|
||||
def list_list():
|
||||
def list_list() -> ResponseReturnValue:
|
||||
lists = MirrorList.query.filter(MirrorList.destroyed == None).all()
|
||||
return render_template("list.html.j2",
|
||||
section="list",
|
||||
|
@ -48,7 +50,7 @@ def list_list():
|
|||
|
||||
|
||||
@bp.route('/preview/<format_>')
|
||||
def list_preview(format_: str):
|
||||
def list_preview(format_: str) -> ResponseReturnValue:
|
||||
if format_ == "bca":
|
||||
return Response(json.dumps(mirror_mapping()), content_type="application/json")
|
||||
if format_ == "bc2":
|
||||
|
@ -59,7 +61,7 @@ def list_preview(format_: str):
|
|||
|
||||
|
||||
@bp.route("/destroy/<list_id>", methods=['GET', 'POST'])
|
||||
def list_destroy(list_id: int):
|
||||
def list_destroy(list_id: int) -> ResponseReturnValue:
|
||||
list_ = MirrorList.query.filter(MirrorList.id == list_id, MirrorList.destroyed == None).first()
|
||||
if list_ is None:
|
||||
return response_404("The requested bridge configuration could not be found.")
|
||||
|
@ -76,10 +78,10 @@ def list_destroy(list_id: int):
|
|||
|
||||
@bp.route("/new", methods=['GET', 'POST'])
|
||||
@bp.route("/new/<group_id>", methods=['GET', 'POST'])
|
||||
def list_new(group_id=None):
|
||||
def list_new(group_id: Optional[int] = None) -> ResponseReturnValue:
|
||||
form = NewMirrorListForm()
|
||||
form.provider.choices = [(k, v) for k, v in MirrorList.providers_supported]
|
||||
form.format.choices = [(k, v) for k, v in MirrorList.formats_supported]
|
||||
form.provider.choices = [(k, v) for k, v in MirrorList.providers_supported] # type: ignore
|
||||
form.format.choices = [(k, v) for k, v in MirrorList.formats_supported] # type: ignore
|
||||
if form.validate_on_submit():
|
||||
list_ = MirrorList()
|
||||
list_.provider = form.provider.data
|
||||
|
@ -105,7 +107,7 @@ def list_new(group_id=None):
|
|||
return render_template("new.html.j2", section="list", form=form)
|
||||
|
||||
|
||||
class NewMirrorListForm(FlaskForm):
|
||||
class NewMirrorListForm(FlaskForm): # type: ignore
|
||||
provider = SelectField('Provider', validators=[DataRequired()])
|
||||
format = SelectField('Distribution Method', validators=[DataRequired()])
|
||||
description = StringField('Description', validators=[DataRequired()])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue