Skip to content

bug(stubgen): instance variables defined in __init__ method are missing from generated stubs #3208

Closed

Description

@tobyh-canva

Summary

Classes in generated stubs are missing attributes if those attributes are not explicitly annotated at the class-level. The classic canonical, non-dataclass way of defining attributes in __init__(self, ...) is seemingly incompatible with stubgen.

Example

Input

class A:
    def __init__(self, name: str) -> None:
        self.name = name

Expected result

class A:
    name: str

    def __init__(self, name: str) -> None: ...

Actual result

class A:
    def __init__(self, name: str) -> None: ...

Activity

  1. github-actions commented on May 9, 2026

    @github-actions

    This issue has someone assigned, but has not had recent activity for more than 2 weeks.

    If you are still working on this issue, please add a comment so everyone knows. Otherwise, please unassign yourself and allow someone else to take over.

    Thank you for your contributions!

  2. stroxler commented on May 15, 2026

    @stroxler
    Contributor

    If I'm reading the history correctly, this was fixed in #3209 (thanks for the PR!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions