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

How should sqlite3.Row be hinted #8027

Closed
altendky opened this issue Jun 7, 2022 · 5 comments · Fixed by #8036
Closed

How should sqlite3.Row be hinted #8027

altendky opened this issue Jun 7, 2022 · 5 comments · Fixed by #8036

Comments

@altendky
Copy link
Contributor

altendky commented Jun 7, 2022

sqlite3.Row was made generic in python/typeshed#7641. With that change I'm not clear how to hint an sqlite3.Row. It seems that it was made generic against a single type, but many tables will not use the same type for all columns. Also, i have setup to use the dict-like rows which would require typed-dict-like hinting I guess. I didn't see any relevant discussion in the PR.

@srittau
Copy link
Collaborator

srittau commented Jun 7, 2022

The easiest way to use the generic row type for now is to annotate it using Row[Any]. (python/typing#307 would help here.)

@altendky
Copy link
Contributor Author

altendky commented Jun 7, 2022

Is there a case I'm overlooking where being generic like it is now is useful? Outside of the probably rare corner case of all columns in a table having the same type. At which point there still isn't a hint as to how many columns there are.

@JelleZijlstra
Copy link
Member

Yes, not sure why I made that change; I agree it's likely not useful. I'd be OK with making the class non-Generic again.

@altendky
Copy link
Contributor Author

altendky commented Jun 7, 2022

Is there a path forward, maybe after some other expected changes/features in mypy even, towards a more complete solution? If so then the thrash of removing it may not be worthwhile. It has been present in a few recent mypy releases already. If not, then maybe removal would be good.

@JelleZijlstra
Copy link
Member

There's no currently planned feature that would help here. We'd need something like a TypedDict that is based on an arbitrary class instead of a dict, but that's not a simple feature to add.

altendky added a commit to altendky/typeshed that referenced this issue Jun 8, 2022
Introduced in python#7641.  Removal discussed at python#8027.
@AlexWaygood AlexWaygood linked a pull request Jun 11, 2022 that will close this issue
JelleZijlstra pushed a commit that referenced this issue Jun 11, 2022
Introduced in #7641.  Removal discussed at #8027.
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 a pull request may close this issue.

3 participants