def test_generic_recursive_models_inheritance() -> None:
    """https://github.com/pydantic/pydantic/issues/9969"""

    T = TypeVar('T')

    class M1(BaseModel, Generic[T]):
        bar: 'M1[T]'

    class M2(M1[str]):
        pass

    M2.model_rebuild()

    assert M2.__pydantic_complete__
https://github.com/pydantic/pydantic/issues/9969
tests/test_generics.py