-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add stubs for pyimgui - Dear ImGui bindings #14317
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: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
…into imgui-2.0.0-stubs
This comment has been minimized.
This comment has been minimized.
stubs/imgui/imgui/core.pyi
Outdated
Condition = typing.NewType("Condition", enum.IntFlag) | ||
NONE = typing.cast(Condition, ...) | ||
ALWAYS = typing.cast(Condition, ...) | ||
ONCE = typing.cast(Condition, ...) | ||
FIRST_USE_EVER = typing.cast(Condition, ...) | ||
APPEARING = typing.cast(Condition, ...) |
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.
Cython represents these using plain ints at runtime. IntFlag operations won't work (e.g. NONE.name would raise).
I'd suggest typing these as Final
ints. If the values are stable, you can include them in the stubs.
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.
The idea was to enforce usage of correct enums in certain contexts i.e. using values that fall under the WindowFlags
category in places when such are expected. Using plain int
s then will result in typechecker errors, when user tries to use combination of those flags (with |
operator) (because it expects concrete value).
It appears imgui only supports Python <=3.11. That could be problem for stubtest, which currently runs on Python 3.13 in the CI |
Use `typing_extensions.Self` instead of `typing.Self` Use `ABC`s from `collections.abc` module Use `Final[int]` for int constants inside `__init__.pyi` Use named imports
…contextlib.pyi`)
I personally used imgui mainly with Python 3.12.3 and it worked fine then. I cannot install it on 3.13 and above tho. |
Use custom `_IntFlag` instead of `enum.IntFlag` Use `Final` for constants instead of assignment with `cast` function Use `Callable` from `collections.abc` instead of `typing` module
…into imgui-2.0.0-stubs
This comment has been minimized.
This comment has been minimized.
Remove typehints for `__init__` methods without arguments
…into imgui-2.0.0-stubs
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Additionally flake8 fails with |
No description provided.