Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subclass of generic class not rendering type properly in field list #147

Open
Galarzaa90 opened this issue Apr 18, 2023 · 1 comment
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Galarzaa90
Copy link

Given the following classes:

T = TypeVar('T')


class Paginated(GenericModel, Generic[T]):
    current_page: int = 1
    """The currently viewed page."""
    total_pages: int = 1
    """The total number of pages."""
    results_count: int = 0
    """The total number of entries across all pages."""
    entries: List[T] = []
    """The entries in this page."""

class CMPostArchive(Paginated[CMPost]):
    """Represents the CM Post Archive.

    The CM Post Archive is a collection of posts made in the forum by community managers.
    """
    start_date: datetime.date
    """The start date of the displayed posts."""
    end_date: datetime.date
    """The end date of the displayed posts."""

And in rst:

.. autopydantic_model:: CMPostArchive
   :inherited-members:

The following is rendered:

image

As we can see, in the Fields list, T is replaced by the actual type the class is defining, but when looking at the members list, it still shows T, unless I explicitly override the field in CMPostArchive and set the type there.

@mansenfranzen
Copy link
Owner

Hi @Galarzaa90,

thanks for reporting this bug. This is not intended, indeed.

At moment, I'm short on time and won't be able to provide a quick fix. However, I'm more than happy to help with code review and guidance if you want to provide a PR.

@mansenfranzen mansenfranzen added bug Something isn't working help wanted Extra attention is needed labels Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants