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

Auto-complete on entity construction when using intellisense (VSCode) #715

Open
jat255 opened this issue May 16, 2024 · 0 comments
Open

Comments

@jat255
Copy link

jat255 commented May 16, 2024

I'm brand new to using Pony, but wondering if what I'm expecting to see is possible...

Let's say I create a model/DB table:

class SchemaVersion(db.Entity):
    id = PrimaryKey(int, auto=True)
    version = Required(str, unique=True)
    version_date = Required(date, unique=True)

Later on in my code, I would create a new entity by writing something like sv = SchemaVersion(version='1.0.0', version_date=dt.date.today()). Given that I'm a forgetful programmer, I would hope that it would show me the class attributes when I try to create a new instance, but when I try this in VSCode, I see the following auto-completion:

image

Apart from reimplementing each class's __init__() method, is there a way to structure my code such that Intellisense can pick up the attribute definitions? I guess my question is: is this the intended behavior, or am I doing something incorrect with how I'm defining my models?

It appears to work if I define my model like this, but I'm not sure if this is compatible with how Pony does things (I think it should be, but I'm not sure):

class SchemaVersion(db.Entity):
    id = PrimaryKey(int, auto=True)
    version = Required(str, unique=True)
    version_date = Required(date, unique=True)

    def __init__(self, version: str, version_date: date, **kwargs):
        super().__init__(version=version, version_date=version_date, **kwargs)

image

This also requires writing a lot more boilerplate code for each class, unforunately.

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