[elbe-devel] [PATCH] elbepack: db: restore Debian bullseye compatibility

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Oct 1 09:42:25 CEST 2024


The changes introduced by commit ea1d50498d81
("elbepack: db: make class hierarchy mypy compatible")
are not compatible with Debian bullseye.
Revert them and instead silence mypy through inline annotations.
There are not many ORM classes and those that exist are getting remove
anyways.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/db.py | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/elbepack/db.py b/elbepack/db.py
index c1f1bedba83b224acac4f9eaf5ae2e77011ba410..c13875c3d9e56df3e356c8e725cbff8d6de79822 100644
--- a/elbepack/db.py
+++ b/elbepack/db.py
@@ -28,24 +28,14 @@ from sqlalchemy import (
     create_engine,
 )
 from sqlalchemy.exc import OperationalError
-from sqlalchemy.orm import registry, relationship, scoped_session, sessionmaker
-from sqlalchemy.orm.decl_api import DeclarativeMeta
+from sqlalchemy.orm import declarative_base, relationship, scoped_session, sessionmaker
 from sqlalchemy.orm.exc import NoResultFound
 
 from elbepack.elbeproject import ElbeProject
 from elbepack.elbexml import ElbeXML, ValidationMode
 
 
-mapper_registry = registry()
-
-
-class Base(metaclass=DeclarativeMeta):
-    __abstract__ = True
-
-    registry = mapper_registry
-    metadata = mapper_registry.metadata
-
-    __init__ = mapper_registry.constructor
+Base = declarative_base()
 
 
 class ElbeDBError(Exception):
@@ -598,7 +588,7 @@ class ElbeDB:
             print(str(e))
 
 
-class User(Base):
+class User(Base):  # type: ignore
     __tablename__ = 'users'
 
     id = Column(Integer, Sequence('article_aid_seq', start=1001, increment=1),
@@ -611,7 +601,7 @@ class User(Base):
     projects = relationship('Project', backref='owner')
 
 
-class Project (Base):
+class Project (Base):  # type: ignore
     __tablename__ = 'projects'
 
     builddir = Column(String, primary_key=True)
@@ -637,7 +627,7 @@ class ProjectData:
                              project.edit.microsecond, project.edit.tzinfo)
 
 
-class ProjectFile (Base):
+class ProjectFile (Base):  # type: ignore
     __tablename__ = 'files'
 
     name = Column(String, primary_key=True)

---
base-commit: c26a80131ccb488e70f95d7da75fe45312e79695
change-id: 20240930-bullseye-db-efc4429a27f2

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh at linutronix.de>



More information about the elbe-devel mailing list