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

Type of user_data is None throughout the stubs #149

Open
cebtenzzre opened this issue Jun 14, 2023 · 1 comment · May be fixed by #145
Open

Type of user_data is None throughout the stubs #149

cebtenzzre opened this issue Jun 14, 2023 · 1 comment · May be fixed by #145

Comments

@cebtenzzre
Copy link

user_data is obviously meant for the programmer to put arbitrary data in for later use. At runtime it may be any type. However, user_data is typed as None throughout these stubs.

Here is an example:

import gi

gi.require_version('Gtk', '3.0')

from gi.repository import Gtk

it = Gtk.TreeIter()
it.user_data = 0

This is what mypy says:

$ mypy repr.py
repr.py:8: error: Incompatible types in assignment (expression has type "int", variable has type "None")  [assignment]
Found 1 error in 1 file (checked 1 source file)

Here is the definition of TreeIter in _Gtk3.pyi:

class TreeIter(GObject.GBoxed):
    stamp: int = ...
    user_data: None = ...
    user_data2: None = ...
    user_data3: None = ...
    def copy(self) -> TreeIter: ...
    def free(self) -> None: ...
@mat-xc
Copy link
Collaborator

mat-xc commented Jul 8, 2023

It seems that there is no distinction between void and void* at introspection level, but I think we can avoid to use None where it makes no sense and use Any instead. I will work on this

@mat-xc mat-xc linked a pull request Sep 22, 2023 that will close this issue
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.

2 participants