Skip to content

Lupa stubs: #14359

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Lupa stubs: #14359

wants to merge 4 commits into from

Conversation

jmarianer
Copy link

@jmarianer jmarianer commented Jul 1, 2025

Support get/set/del from Lua tables.
Lua table values are all Any because we can't typecheck across language boundaries.
Support unpack_returned_tuples in the LuaRuntime constructor.

Support get/set/del from Lua tables.
Lua table values are all Any because we can't typecheck across language boundaries.
Support unpack_returned_tuples in the LuaRuntime constructor.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Tue Jul 1 16:43:21 2025 -0700
#
# On branch main
# Your branch is ahead of 'origin/main' by 1 commit.
#   (use "git push" to publish your local commits)
#
# Changes to be committed:
#	modified:   lua51.pyi
#	modified:   lua52.pyi
#	modified:   lua53.pyi
#	modified:   lua54.pyi
#
@jmarianer
Copy link
Author

The failing check is easy enough to fix, but I found a possible way to get around the Any and I need to test it, so I'll be a while.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Jul 2, 2025

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, remarks below. Please note that I only left remarks on the first file, but they apply to all files.

@@ -70,8 +73,7 @@ class LuaRuntime:
lua_implementation: Final[str]
lua_version: Final[tuple[int, int]]

# @classmethod
# def __cinit__(cls, unpack_return_tuples: bool) -> None: ...
def __init__(self, /, unpack_returned_tuples: bool, *args: Any) -> None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that we need a comment for each Any, explaining which types are allowed and/or how it's used.

Comment on lines +47 to +48
LuaKey: TypeAlias = str | int
LuaObject: TypeAlias = _LuaTable | int | str | float | bool | None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, these are not available at runtime, so we need to preface them with an underscore.

You could also consider adding a lupa._types modules where you define these type-check only items and just import them, but that's just an option.

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