Skip to content

Conversation

@jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Mar 9, 2023

No description provided.

@jtojnar jtojnar force-pushed the gio-generic-list branch from b96cc91 to c111163 Compare March 9, 2023 12:31
@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 9, 2023

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 subscriptable

Edit: Opened https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/237

@jtojnar jtojnar marked this pull request as draft March 21, 2023 11:10
def __getitem__(self, position: int) -> GObject.Object: ...
def __iter__(self) -> Iterator[GObject.Object]: ...
class ListModel(GObject.GInterface, Generic[ItemType]):
# override
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@jamiethecat
Copy link
Contributor

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 :)

@lovetox
Copy link
Collaborator

lovetox commented Jan 2, 2026

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

@jamiethecat
Copy link
Contributor

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)

@lovetox
Copy link
Collaborator

lovetox commented Jan 2, 2026

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 Gio.ListModel[GObject] for example.

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.

@jtojnar
Copy link
Contributor Author

jtojnar commented Jan 3, 2026

Odd minor versions are unstable: https://pygobject.gnome.org/changelog.html

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.

3 participants