typing: GObject: Type Properties using inference#237
Open
kra-mo wants to merge 1 commit intopygobject:masterfrom
Open
typing: GObject: Type Properties using inference#237kra-mo wants to merge 1 commit intopygobject:masterfrom
kra-mo wants to merge 1 commit intopygobject:masterfrom
Conversation
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.
Collaborator
|
But subscription does not work type 'Property' is not subscriptableThis 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 |
Author
|
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? |
Collaborator
|
Yes i would say this should be added first in pygobject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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