Skip to content

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

@tobyh-canva

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: ...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions