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

Fix SQLite Aggregation Protocols #12192

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

max-muoto
Copy link
Contributor

@max-muoto max-muoto commented Jun 23, 2024

Fix issues detailed in #12141.

@max-muoto max-muoto changed the title feat: Improve/fix sqlite aggregration protocols Fix SQLite Aggregation Protocols Jun 23, 2024

This comment has been minimized.

@max-muoto max-muoto marked this pull request as ready for review June 23, 2024 19:34

This comment has been minimized.

@max-muoto max-muoto marked this pull request as draft June 23, 2024 20:04

class _WindowAggregateClass(Protocol):
step: Callable[..., object]
Copy link
Contributor Author

@max-muoto max-muoto Jun 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From testing things out, it doesn't seem this protocol really works as intended in either MyPy or Pyright. Unless you actually were annotating a lambda perhaps. Due to this, I went ahead and removed it.

Some examples of how it might not work as you would expect:

Pyright Playground

MyPy Playground

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been part of the initial commit in #7625, while the other protocols already used a function. Maybe @JelleZijlstra remembers why we used an attribute instead of a function here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really remember what I was thinking when I wrote that code, but the annotations proposed in this PR mean that protocol implementations must take *args. I am not familiar with how these things are used, but I'd expect concrete implementations to only accept a fixed number of parameters. Maybe that's why I chose to use Callable[....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried messing around with TypeVarTuples to do that, but had some issues there as well, there might not be a great way, but I'll see if I can figure something out.

This comment has been minimized.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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

Successfully merging this pull request may close these issues.

None yet

3 participants