-
Notifications
You must be signed in to change notification settings - Fork 41
typing: Gio: Make ListModel and ListStore generic #115
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
base: master
Are you sure you want to change the base?
Conversation
b96cc91 to
c111163
Compare
|
Hmm, my app crashes when I try to use it so probably requires changes to pygobject itself: Traceback (most recent call last):
File "/nix/store/m8l8vlxnp3a5wbvrx162qzjfakbayds8-nonemast-0.1.0/bin/..nonemast-wrapped-wrapped", line 30, in <module>
from nonemast import main
File "/nix/store/m8l8vlxnp3a5wbvrx162qzjfakbayds8-nonemast-0.1.0/share/nonemast/nonemast/main.py", line 11, in <module>
from .window import NonemastWindow
File "/nix/store/m8l8vlxnp3a5wbvrx162qzjfakbayds8-nonemast-0.1.0/share/nonemast/nonemast/window.py", line 19, in <module>
from .operations import ensure_coauthors
File "/nix/store/m8l8vlxnp3a5wbvrx162qzjfakbayds8-nonemast-0.1.0/share/nonemast/nonemast/operations/ensure_coauthors.py", line 17, in <module>
def ensure_coauthors(updates: Gio.ListStore[PackageUpdate]) -> None:
TypeError: 'GObjectMeta' object is not subscriptableEdit: Opened https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/237 |
c111163 to
55f34ca
Compare
| def __getitem__(self, position: int) -> GObject.Object: ... | ||
| def __iter__(self) -> Iterator[GObject.Object]: ... | ||
| class ListModel(GObject.GInterface, Generic[ItemType]): | ||
| # override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think thats necessary, if the class itself has a "override" annotation, then it will be completely ignored by the generator. So no need to add override to each method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some methods without override. I think it might be helpful to keep methods marked, and temporarily remove the class mark to regenerate the unmarked ones when updating.
|
https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/237 has been merged and is in a stable release now, so it'd be nice to finish this MR too :) |
|
hm, but this will lead to type checking errors for everyone that does not use the latest pygobject release, maybe we should wait a bit |
|
Doesn't it only lead to a runtime error if you're using an older PyGObject, while trying to use newer PyGObject functionality? Because in that case, i don't think it's that bad. (it's very annoying to cast all my list models purely because stubs doesn't expose what upstream already has atm) |
|
Its a type error if you dont subscribe a variable if it is subscriptable so say you have a callback where the list model is passed as var, then the type checker wants you to do But this will lead to a runtime error for anyone that does not use pygobject 3.55. This means everyone who does not want or cant use pygobject would be frozen to the the current stable version of the stubs, or would need to add a lot of # ignore comments. I guess this is ok. i just discovered that 3.55 is also not on pypi yet. |
|
Odd minor versions are unstable: https://pygobject.gnome.org/changelog.html |
55f34ca to
4be1943
Compare
4be1943 to
00ce09d
Compare
No description provided.