Skip to content

Syntax error in imgui_bundle/implot/internal.pyi prevents type checking (of external libs) if imgui-bundle is imported #348

@tlambert03

Description

@tlambert03

Hello and thanks for this great bundle

Im running into issues when running mypy even on my own code due to a syntax error in the autogenerated stubs at imgui_bundle/implot/internal.pyi. In other words, I'm not trying to type check imgui-bundle... just my own code:

$ mypy src     
.venv/lib/python3.13/site-packages/imgui_bundle/implot/internal.pyi:2241: error: invalid syntax. Perhaps you forgot a comma? 
[syntax]
    def mk_time(ptm: struct tm) -> Time:
                      ^
Found 1 error in 1 file (errors prevented further checking)

Unfortunately, it looks like mypy itself doesn't offer a good way to just ignore syntax errors in external libraries (this is similar to python/mypy#6897) ... so i'm reaching for wonky workarounds to try to both use imgui-bundle, while still being able to type check my own code.

I tried cloning this repo to see how hard it would be to correct

def mk_time(ptm: struct tm) -> Time:

to

def mk_time(ptm: tm) -> Time:

but naturally, if I rerun python external/implot/bindings/generate_implot.py my changes get overwritten.

I'd be happy to submit a PR if you can guide me as to where such a change should be made. If this is ultimately something that needs to be fixed in litgen, would you accept a simple post-generation search-and-replace correction?

Specifically: I'm proposing adding the following to generate_implot.py

    stubfile = Path(STUB_DIR + "/implot/internal.pyi")
    txt = stubfile.read_text()
    txt = txt.replace("ptm: struct tm", "ptm: tm")
    stubfile.write_text(txt)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions