Here's a minimal reproduction:
import dataclasses
from typing import Generic, TypeVar
import databind.json
T = TypeVar("T")
@dataclasses.dataclass
class A(Generic[T]):
a_field: int
@dataclasses.dataclass
class B(A):
b_field: str
b = B(2, "hi")
out = databind.json.get_object_mapper().serialize(b, B)
print(out) # prints `{'b_field': 'hi'}`, which is wrong.
I've traced this to this line, which adds to the queue base in (hint.bases or hint.type.__bases__).
When T is uninstantiated, the former is non-empty, so the base dataclasses that come the normal way don't get added.
I don't fully understand this code but I think the fix is:
for base in (*hint.bases, *hint.type.__bases__)
to make sure we iterate over everything.