From 66330675636559c2bb5bb7d47da84ad4f667996b Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Tue, 1 Dec 2026 09:43:23 +0100 Subject: [PATCH] Turn the ORM `Base` into a real class --- pyproject.toml | 4 ++-- src/velofy/db/meta.py | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 28d62be..f45a128 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -449,8 +449,8 @@ disallow_any_generics = true # Disallow functions with incomplete type annotations disallow_incomplete_defs = true -# Allow subclassing `Any` as long as the ORM models' `Base` is untyped -disallow_subclassing_any = false +# Disallow subclassing classes typed `Any` +disallow_subclassing_any = true # Disallow calling functions without type annotations ... disallow_untyped_calls = true diff --git a/src/velofy/db/meta.py b/src/velofy/db/meta.py index 3901514..73a6a7d 100644 --- a/src/velofy/db/meta.py +++ b/src/velofy/db/meta.py @@ -1,15 +1,15 @@ """Provide the ORM's declarative base.""" -import typing as t - import sqlalchemy as sa from sqlalchemy import orm import velofy -Base: t.Any = orm.declarative_base( - metadata=sa.MetaData( +class Base(orm.DeclarativeBase): + """The declarative base of all ORM models.""" + + metadata = sa.MetaData( schema=velofy.config.CLEAN_SCHEMA, naming_convention={ "pk": "pk_%(table_name)s", @@ -18,5 +18,4 @@ Base: t.Any = orm.declarative_base( "ix": "ix_%(table_name)s_on_%(column_0_N_name)s", "ck": "ck_%(table_name)s_on_%(constraint_name)s", }, - ), -) + )