Skip to content

Conversation

@kra-mo
Copy link

@kra-mo kra-mo commented Nov 10, 2025

This seems to work consistently, automatically unless you rely on the implicit nullability of a property. In that case, you will need to manually type it as:

prop = GObject.Property[T | None](type=T)

However, given that this behavior is ignored in other places and that the alternative would be wildly more annoying to deal with, it should probably be fine.

See https://gitlab.gnome.org/GNOME/pygobject/-/issues/701

This seems to work consistently, automatically
unless you rely on the implicit nullability of a property.
In that case, you will need to manually type it as:

```
prop = GObject.Property[T | None](type=T)
```

However, given that this behavior is ignored in other places
and that the alternative would be wildly more annoying
to deal with, it should probably be fine.
@lovetox
Copy link
Collaborator

lovetox commented Jan 2, 2026

But subscription does not work

type 'Property' is not subscriptable

This would have to be added in pygobject

And marking the object in the stubs as subscriptable, when it then leads to a runtime error is ugly

@kra-mo
Copy link
Author

kra-mo commented Jan 2, 2026

Hmm yeah, I guess you indeed wouldn't be able to specify it manually without changes in PyGObject.

Given that we've done the same with ListModel without runtime guarantees either, I guess we could add this upstream as a "useless" generic first?

@lovetox
Copy link
Collaborator

lovetox commented Jan 2, 2026

Yes i would say this should be added first in pygobject

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.

2 participants