[Python] Why doesn’t Pylance provide autocompletion for dynamically created dataclass in...

Discussão em 'Python' iniciado por Stack, Março 18, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to dynamically create a dataclass using make_dataclass in Python. However, when I hover over User in VS Code (with Pylance enabled), I don’t get autocompletion for attributes like "name" and "age".

    Here is the code

    from dataclasses import make_dataclass

    def test():
    User = make_dataclass("User", [("name", str), ("age", int)])
    user = User(name=) # No autocompletion in VS Code

    Continue reading...

Compartilhe esta Página