diff --git a/main.py b/main.py index 2953dad..85cc628 100644 --- a/main.py +++ b/main.py @@ -18,6 +18,28 @@ from flask_ldap3_login import LDAP3LoginManager from flask_login import LoginManager, login_user, login_required, UserMixin, current_user, logout_user from flask_ldap3_login.forms import LDAPLoginForm +# DEAL WITH MIGRATION TO SQLALCHEMY 2.0 +import warnings +from sqlalchemy import exc + +# for warnings not included in regex-based filter below, just log +warnings.filterwarnings("always", category=exc.Base20DeprecationWarning) + +# for warnings related to execute() / scalar(), raise +for msg in [ + r"The (?:Executable|Engine)\.(?:execute|scalar)\(\) function", + r"The current statement is being autocommitted using implicit autocommit,", + r"The connection.execute\(\) method in SQLAlchemy 2.0 will accept " + "parameters as a single dictionary or a single sequence of " + "dictionaries only.", + r"The Connection.connect\(\) function/method is considered legacy", + r".*DefaultGenerator.execute\(\)", +]: + warnings.filterwarnings( + "error", + message=msg, + category=exc.Base20DeprecationWarning, + ) # pylint: disable=no-member