def test_model_docs_duplicate_class():
    """Ensure source parsing is working correctly when using frames."""

    @dec_noop
    class MyModel(BaseModel):
        a: int
        """A docs"""

        model_config = ConfigDict(
            use_attribute_docstrings=True,
        )

    @dec_noop
    class MyModel(BaseModel):
        b: int
        """B docs"""

        model_config = ConfigDict(
            use_attribute_docstrings=True,
        )

    assert MyModel.model_fields['b'].description == 'B docs'

    # With https://github.com/python/cpython/pull/106815/ introduced,
    # inspect will fallback to the last found class in the source file.
    # The following is to ensure using frames will still get the correct one
    if True:

        class MyModel(BaseModel):
            a: int
            """A docs"""

            model_config = ConfigDict(
                use_attribute_docstrings=True,
            )

    else:

        class MyModel(BaseModel):
            b: int
            """B docs"""

            model_config = ConfigDict(
                use_attribute_docstrings=True,
            )

    assert MyModel.model_fields['a'].description == 'A docs'
Ensure source parsing is working correctly when using frames.
tests/test_docs_extraction.py