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

Attr query by class variables. #19

Open
wesleyearlstander opened this issue Feb 14, 2024 · 1 comment
Open

Attr query by class variables. #19

wesleyearlstander opened this issue Feb 14, 2024 · 1 comment

Comments

@wesleyearlstander
Copy link

Hi team,

So I've had a look at the mechanism for querying and I feel as if it's very close to complete. My only question would be to perhaps rework the way that the query works to allow for the feeding in of class and its hinted variables. Then the work is offloaded to the Attr library internally.

This would allow for auto-completion when querying an object. I haven't played with the library but from the looks of it, you won't get static analysis on those variables from the Attr class.

This I think would be the final implementation change that would make the library extra-ordinary and bring it into wide usage.

I will re-iterate that this library is fantastic and I'm extremely grateful for the work already done on it. I'm curious if I can find a way to implement the above so I'll try take a look at it.

@nayaverdier
Copy link
Owner

That's a great idea. I'm not sure if there's a way to automatically treat the types of the class (e.g. MyTable.some_field) as Attr while still keeping MyTable(...).some_field as the original type defined, at least for the purposes of autocompletion. If you can find some way, that would be fantastic.

It looks like SQLAlchemy uses Mapped to provide this functionality, but this requires hinting all fields as Mapped[int], etc.

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

2 participants