Skip to content

Workflow scripts#5

Open
arsym-dev wants to merge 4 commits intomainfrom
workflow_scripts
Open

Workflow scripts#5
arsym-dev wants to merge 4 commits intomainfrom
workflow_scripts

Conversation

@arsym-dev
Copy link
Copy Markdown
Collaborator

Added scripts to generate stubs and merge them back into renpy. I updated the stubs in later commits

Couple of issues:

  • merge_pyi only works up to python 3.12 since the project will no longer be maintained
  • merge_pyi is very eager to move things to imports. For example, if you want to do:
textshaders: dict[str, renpy.text.shader.TextShader]

it'll want to do:

from renpy.text.shader import TextShader as TextShader
...
textshaders: dict[str, TextShader]
  • If __init__() sets the value of a class attribute, stubgen may sometimes reset the type of that attribute to Incomplete until the __init__() typing is updated.

@Andykl
Copy link
Copy Markdown
Member

Andykl commented Dec 16, 2025

Things that looks incorrect at first glance:

  1. You delete py.typed (it is renamed to scripts/init.py) which is incorrect. If that file does not exists typecheckers will then continue to look for more stubs.
  2. Namespace package is a thing, so we don't need an empty __init__.py
  3. pygame.compat removal is merged into main, so we don't need to ignore it, but the code to ignore files is worth having.
  4. You mix uses of pathlib and os.path. IMO, pathlib object-based approach is easier to understand.
  5. We would need to choose what approach we suggest to use, uv or pip. I prefer uv but it is not a strong preference.
  6. Because pyright can't read pyx files, it can't extract docstring for functions, so I think it is better if pyi files for cython modules keep doc strings.

@Andykl
Copy link
Copy Markdown
Member

Andykl commented Dec 16, 2025

I will look closer how merge-pyi works tomorrow, probably we can write our own solution that would analyze AST/tockens of the file to extract/merge the data.

@arsym-dev
Copy link
Copy Markdown
Collaborator Author

Basically it's a wrapper around LibCST. You can find out more here:

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