Skip to content

Litestar store adapters do not inherit litestar.stores.base.Store, so registry use requires a type suppression #681

Description

@cofin

Summary

The Litestar store adapters implement the full litestar.stores.base.Store interface but none of them subclass it. Because Store is an ABC rather than a Protocol, structural conformance is not enough — passing one to anything annotated Store, such as registering it in a StoreRegistry, is a type error that only a suppression can clear.

Reproducer

import importlib, inspect
from litestar.stores.base import Store

for mod in ["asyncpg", "aiosqlite", "psycopg", "oracledb", "duckdb", "sqlite", "asyncmy"]:
    try:
        m = importlib.import_module(f"sqlspec.adapters.{mod}.litestar")
    except Exception:
        continue
    for name, obj in vars(m).items():
        if inspect.isclass(obj) and name.endswith("Store"):
            print(f"{name:20} subclasses Store: {issubclass(obj, Store)}")

On sqlspec 0.58.2:

AsyncpgStore         subclasses Store: False
AiosqliteStore       subclasses Store: False
OracleAsyncStore     subclasses Store: False
OracleSyncStore      subclasses Store: False
DuckdbStore          subclasses Store: False
SQLiteStore          subclasses Store: False

Every one of them already provides the full abstract surface — get, set, delete, delete_all, exists, expires_in — so this is a declaration gap, not a functional one. Checked with:

all(hasattr(AsyncpgStore, m) for m in Store.__abstractmethods__)  # True

Impact

Any application wiring one of these into Litestar's store registry gets a type error at the registration site and has to suppress it. The suppression is permanent, because nothing about it will ever resolve on its own.

Suggested fix

Have the adapter stores inherit litestar.stores.base.Store. They already satisfy it, so this should be a declaration change rather than a behavioural one.

Alternatively this could be raised against Litestar, to have the registry accept a protocol rather than the ABC. Filing here because inheriting is the smaller and more local change, but happy to move it if the other direction is preferred.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions