How can I disable ExtDeprecationWarning for external libs in flask

后端 未结 2 1150
故里飘歌
故里飘歌 2021-01-17 20:04

When I run my script, I get this output:

/app/venv/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.sqlalchemy is          


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-17 20:25

    I cannot decide for sure from your question, but I'm pretty sure it's the imports within your source files that're causing these warnings.

    If you are using the deprecated flask.ext import redirect, then for example:

    flask.ext.sqlalchemy import SQLAlchemy()
    

    Becomes a direct import:

    from flask_sqlalchemy import SQLAlchemy()
    

    If you're using Linux, this one-liner will make the change in all your files and folders recursively (from ./).

    Back up first to a different file path - I cannot say with certainty it will not corrupt the contents of a .git directory, or other svn you use, etc. Or just make the amendments manually.

    find ./ -type f exec sed -i 's/flask.ext./flask_/g' {} \;
    

提交回复
热议问题