pallets-eco / flask-sqlalchemy

Adds SQLAlchemy support to Flask

Home Page:https://flask-sqlalchemy.readthedocs.io

Repository from Github https://github.compallets-eco/flask-sqlalchemyRepository from Github https://github.compallets-eco/flask-sqlalchemy

AttributeError: module 'sqlalchemy.orm' has no attribute 'DeclarativeBase'

InoreNeronI opened this issue · comments

___________________________________ ERROR collecting tests/test_config.py ____________________________________
__pypackages__/3.11/lib/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
__pypackages__/3.11/lib/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
__pypackages__/3.11/lib/_pytest/python.py:531: in collect
    self._inject_setup_module_fixture()
__pypackages__/3.11/lib/_pytest/python.py:545: in _inject_setup_module_fixture
    self.obj, ("setUpModule", "setup_module")
__pypackages__/3.11/lib/_pytest/python.py:310: in obj
    self._obj = obj = self._getobj()
__pypackages__/3.11/lib/_pytest/python.py:528: in _getobj
    return self._importtestmodule()
__pypackages__/3.11/lib/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
__pypackages__/3.11/lib/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1204: in _gcd_import
    ???
<frozen importlib._bootstrap>:1176: in _find_and_load
    ???
<frozen importlib._bootstrap>:1147: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
__pypackages__/3.11/lib/_pytest/assertion/rewrite.py:186: in exec_module
    exec(co, module.__dict__)
tests/test_config.py:5: in <module>
    from util.main import (register_commands, register_error_handlers,
src/util/main.py:19: in <module>
    from command.db import drop, init, load, migrate, shell, url
src/command/db.py:14: in <module>
    from model.main import Mail, Role, Text, User
src/model/main.py:11: in <module>
    from util.extensions import db
src/util/extensions.py:10: in <module>
    from flask_sqlalchemy import SQLAlchemy
__pypackages__/3.11/lib/flask_sqlalchemy/__init__.py:5: in <module>
    from .extension import SQLAlchemy
__pypackages__/3.11/lib/flask_sqlalchemy/extension.py:40: in <module>
    t.Type[sa_orm.DeclarativeBase],
E   AttributeError: module 'sqlalchemy.orm' has no attribute 'DeclarativeBase'

Environment:

  • Python version: 3.11
  • Flask-SQLAlchemy version: 3.1.1
  • SQLAlchemy version: 2.0.23

I am using Pythonloc with Make under Ubuntu, steps to reproduce:

  1. Clone this repository: https://github.com/InoreNeronI/Eguraldia
  2. Make sure you have Node LTS installed and add this path to the environment variable: $(HOME)/.local/bin
  3. Run make update and after make test
commented

A minimal (which certainly does not involve cloning a full application's repo nor installing node ;)) example to reproduce this would be appreciated!

I am sorry, but the only workaround to minimize testing skipping Node LTS installation is to comment the line number 170 in the Makefile:

# npm --prefix assets upgrade