1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-08 21:21:06 +00:00

Apply pyright

This commit is contained in:
Mo 2022-08-15 22:22:36 +02:00
parent fe4788229b
commit 33b08ab383
14 changed files with 26 additions and 21 deletions

View file

@ -1,5 +1,5 @@
from flask_migrate import Migrate from flask_migrate import Migrate
from flask_security import SQLAlchemyUserDatastore from flask_security.datastore import SQLAlchemyUserDatastore
from .config import get_settings from .config import get_settings
from .models import db, User, Role from .models import db, User, Role
@ -29,7 +29,7 @@ def create_app(create_for_server=True):
migrate.init_app(app, db) migrate.init_app(app, db)
# Setup Flask-Security-Too # Setup Flask-Security-Too
from flask_security import Security from flask_security.core import Security
Security(app, user_datastore) Security(app, user_datastore)

View file

@ -10,7 +10,9 @@ from flask_admin.contrib.sqla.fields import QuerySelectField, QuerySelectMultipl
from flask_admin.contrib.sqla.filters import BooleanEqualFilter, FilterEqual from flask_admin.contrib.sqla.filters import BooleanEqualFilter, FilterEqual
from flask_admin.helpers import get_form_data from flask_admin.helpers import get_form_data
from flask_admin.menu import MenuLink from flask_admin.menu import MenuLink
from flask_security import admin_change_password, current_user, hash_password from flask_login import current_user
from flask_security.changeable import admin_change_password
from flask_security.utils import hash_password
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed, FileField, FileRequired from flask_wtf.file import FileAllowed, FileField, FileRequired
from matplotlib.figure import Figure from matplotlib.figure import Figure
@ -366,6 +368,7 @@ class SemesterView(SecureAdminModelView):
transferAssistants=form.transfer_assistants.data, transferAssistants=form.transfer_assistants.data,
) )
@staticmethod
def addMenuLink(space, newSemester): def addMenuLink(space, newSemester):
categoryText = "Active semester" categoryText = "Active semester"
link = MenuLink( link = MenuLink(

View file

@ -10,7 +10,7 @@ def flashRandomPassword(email: str, password: str):
flash(f"New random password for email {email}: {password}", category="warning") flash(f"New random password for email {email}: {password}", category="warning")
def deep_getattr(object, composed_name): def deep_getattr(object, composed_name: str):
names = composed_name.split(".") names = composed_name.split(".")
attr = getattr(object, names[0]) attr = getattr(object, names[0])
for name in names[1:]: for name in names[1:]:
@ -19,7 +19,7 @@ def deep_getattr(object, composed_name):
return attr return attr
def str_without_semester_formatter(view, context, model, name): def str_without_semester_formatter(view, context, model, name: str):
attr = deep_getattr(model, name) attr = deep_getattr(model, name)
if attr is None: if attr is None:
@ -32,7 +32,7 @@ def str_without_semester_formatter(view, context, model, name):
return attr.str_without_semester() return attr.str_without_semester()
def str_formatter(view, context, model, name): def str_formatter(view, context, model, name: str):
attr = deep_getattr(model, name) attr = deep_getattr(model, name)
if attr is None: if attr is None:
@ -53,7 +53,7 @@ def _default_attr_formatter(attr):
return attr return attr
def link_formatter(model, name, endpoint, attr_formatter=_default_attr_formatter): def link_formatter(model, name: str, endpoint, attr_formatter=_default_attr_formatter):
attr = deep_getattr(model, name) attr = deep_getattr(model, name)
if attr is None: if attr is None:
@ -77,7 +77,7 @@ def link_formatter_factory(endpoint, attr_formatter=_default_attr_formatter):
return formatter return formatter
def email_formatter(view, context, model, name): def email_formatter(view, context, model, name: str):
attr = deep_getattr(model, name) attr = deep_getattr(model, name)
if attr is None: if attr is None:
@ -86,7 +86,7 @@ def email_formatter(view, context, model, name):
return Markup(f"<a href='mailto:{escape(attr)}'>{escape(attr)}</a>") return Markup(f"<a href='mailto:{escape(attr)}'>{escape(attr)}</a>")
def experiment_marks_missing_formatter(view, context, model, name): def experiment_marks_missing_formatter(view, context, model, name: str):
experiment_marks_missing = getattr(model, name) experiment_marks_missing = getattr(model, name)
if experiment_marks_missing is True: if experiment_marks_missing is True:
return Markup("<span style='color: red;'>Yes</span>") return Markup("<span style='color: red;'>Yes</span>")

View file

@ -2,7 +2,8 @@ from flask import flash, redirect, request, url_for
from flask_admin import Admin as FlaskAdmin from flask_admin import Admin as FlaskAdmin
from flask_admin import expose from flask_admin import expose
from flask_admin.model.template import EndpointLinkRowAction from flask_admin.model.template import EndpointLinkRowAction
from flask_security import admin_change_password, current_user from flask_login import current_user
from flask_security.changeable import admin_change_password
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from .advlabdb_independent_funs import ( from .advlabdb_independent_funs import (

View file

@ -3,7 +3,7 @@ from flask_admin import AdminIndexView, BaseView, expose
from flask_admin.contrib.sqla import ModelView from flask_admin.contrib.sqla import ModelView
from flask_admin.helpers import get_form_data from flask_admin.helpers import get_form_data
from flask_admin.model.helpers import get_mdict_item_or_list from flask_admin.model.helpers import get_mdict_item_or_list
from flask_security import current_user from flask_login import current_user
from sqlalchemy import select from sqlalchemy import select
from .exceptions import DatabaseException, ModelViewException from .exceptions import DatabaseException, ModelViewException

View file

@ -73,8 +73,6 @@ def importFromFile(filePath):
expectingTable = True expectingTable = True
readHeader = False readHeader = False
activeDict = None
for line in f: for line in f:
line = line[:-1] line = line[:-1]

View file

@ -6,7 +6,7 @@ from functools import cache
from flask import flash from flask import flash
from flask_admin.menu import MenuLink from flask_admin.menu import MenuLink
from flask_security import current_user from flask_login import current_user
from wtforms.fields import BooleanField, IntegerField, SelectField, StringField from wtforms.fields import BooleanField, IntegerField, SelectField, StringField
from wtforms.validators import DataRequired, NumberRange, Optional from wtforms.validators import DataRequired, NumberRange, Optional

View file

@ -9,7 +9,7 @@ https://flask-sqlalchemy.palletsprojects.com/en/2.x/models/
from decimal import ROUND_HALF_UP, Decimal from decimal import ROUND_HALF_UP, Decimal
from flask import flash from flask import flash
from flask_security import current_user from flask_login import current_user
from flask_security.models import fsqla_v2 as fsqla from flask_security.models import fsqla_v2 as fsqla
from flask_security.models.fsqla_v2 import FsRoleMixin, FsUserMixin from flask_security.models.fsqla_v2 import FsRoleMixin, FsUserMixin
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
@ -253,6 +253,7 @@ class GroupExperiment(db.Model):
def __str__(self): def __str__(self):
return self.str() return self.str()
@staticmethod
def check(semester_experiment, group): def check(semester_experiment, group):
for partStudent in group.part_students: for partStudent in group.part_students:
student = partStudent.student student = partStudent.student

View file

@ -1,5 +1,6 @@
from flask import Blueprint, flash, redirect, request, url_for from flask import Blueprint, flash, redirect, request, url_for
from flask_security import auth_required, current_user from flask_login import current_user
from flask_security.decorators import auth_required
from .model_dependent_funs import active_semester_str from .model_dependent_funs import active_semester_str
from .models import Semester, db from .models import Semester, db

View file

@ -1,5 +1,5 @@
import click import click
from flask_security import admin_change_password from flask_security.changeable import admin_change_password
from sqlalchemy import select from sqlalchemy import select
from advlabdb import create_app from advlabdb import create_app

View file

@ -2,7 +2,7 @@ from pathlib import Path
import click import click
from email_validator import validate_email from email_validator import validate_email
from flask_security import hash_password from flask_security.utils import hash_password
from advlabdb import create_app, settings, user_datastore from advlabdb import create_app, settings, user_datastore
from advlabdb.model_independent_funs import randomPassword from advlabdb.model_independent_funs import randomPassword

View file

@ -7,7 +7,7 @@ from test.experiment_titles import experiment_titles
from test.student_names import student_names from test.student_names import student_names
import click import click
from flask_security import hash_password from flask_security.utils import hash_password
from advlabdb import create_app, settings, user_datastore from advlabdb import create_app, settings, user_datastore
from advlabdb.exceptions import DatabaseException from advlabdb.exceptions import DatabaseException

2
poetry.lock generated
View file

@ -506,7 +506,7 @@ email = ["email-validator"]
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.10" python-versions = "^3.10"
content-hash = "62210a57e60dcbadfb408e2ee9a59e77ccc9c9a4b2e1944f61885d1e53a4cef5" content-hash = "6c1039990219b6759baf90fddf5ec81ffc800dc3497f32f119fbb66f6f4b2562"
[metadata.files] [metadata.files]
alembic = [ alembic = [

View file

@ -12,9 +12,10 @@ click = ">=8.1.3"
email-validator = ">=1.2.1" email-validator = ">=1.2.1"
flask = ">=2.2.2" flask = ">=2.2.2"
flask-admin = ">=1.6.0" flask-admin = ">=1.6.0"
flask-login = ">=0.6.2"
flask-migrate = ">=3.1.0" flask-migrate = ">=3.1.0"
flask-sqlalchemy = ">=2.5.1"
flask-security-Too = ">=4.1.5" flask-security-Too = ">=4.1.5"
flask-sqlalchemy = ">=2.5.1"
flask-wtf = ">=1.0.1" flask-wtf = ">=1.0.1"
gunicorn = ">=20.1.0" gunicorn = ">=20.1.0"
markupsafe = ">=2.1.1" markupsafe = ">=2.1.1"