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

ASTTransformer - defining the AST metamodel without using the @dataclass decorator #32

Open
ivan-alfonso opened this issue Dec 21, 2023 · 0 comments

Comments

@ivan-alfonso
Copy link

If the AST structure is defined without using the @dataclass decorator, that is, by defining (manually) the constructor method of the classes and the getter and setter methods of each attribute, then it will be necessary to define also all the attributes of the class as static attributes. In the following example, the books attribute, although defined in the constructor method, must also be defined as a static attribute.

class Library(Node):
    books: list["Book"]

    def __init__(self, books:list["Book"]):
        self.books: list("Book") = books

    @property
    def books(self) -> list["Book"]:
        return self.__books

    @books.setter
    def books(self, books: list["Book"]):
        self.__books = books

This is necessary for the ASTTransformer to correctly recognize the attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant