Skip to content

ninja_syntax.pyi stub does not match ninja's writer module #344

@nicholasjng

Description

@nicholasjng

Hi! I'm working on my own Python build backend, and I use ninja to build Python extensions configured in pyproject.toml.

Currently I'm vendoring ninja's file writer module, just as you are doing here:

install(FILES "${ninja_SOURCE_DIR}/misc/ninja_syntax.py" COMPONENT python DESTINATION ninja)

It works just as you would expect, but requires a user installation of ninja on the host machine. To improve the UX, I filed nicholasjng/hanzo#4 as a ticket to pick up a PyPI dependency on ninja, to at least have a fallback in place in case the user does not have ninja installed.

uv add ninja works fine, but I get type checker errors because the ninja_syntax.pyi stub does not match ninja's actual writer class at least in a couple of places: In the Writer.__init__, where output is a TextIOWrapper in ninja proper, but is type-hinted as a str by this package, and in Writer.build(), where outputs is hinted as a List[str], but the writer does in fact accept a Union[str, List[str]].

I can supply a fix if that's of interest. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions