Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ strict = true
enable_error_code = ["ignore-without-code", "truthy-bool", "redundant-expr"]
warn_unreachable = true

# ninja_syntax.py is added by the build from the ninja sources; it is annotated upstream
[[tool.mypy.overrides]]
module = "ninja.ninja_syntax"
ignore_missing_imports = true


[tool.ruff]
src = ["src"]
Expand Down
37 changes: 0 additions & 37 deletions src/ninja/ninja_syntax.pyi

This file was deleted.

9 changes: 9 additions & 0 deletions tests/test_ninja.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import inspect
import os
import pathlib
import subprocess
import sys
import sysconfig
Expand All @@ -9,6 +11,7 @@
from importlib_metadata import distribution

import ninja
from ninja import ninja_syntax

from . import push_argv

Expand Down Expand Up @@ -48,3 +51,9 @@ def test_ninja_script():
assert scripts[0].stem == "ninja"
output = subprocess.check_output([str(scripts[0]), "--version"]).decode("ascii")
assert output.splitlines()[0] == expected_version


def test_ninja_syntax_typed():
"""Type checkers must use the annotations in ninja_syntax.py, not an outdated stub."""
assert not pathlib.Path(ninja_syntax.__file__).with_suffix(".pyi").exists()
assert inspect.signature(ninja_syntax.Writer.build).return_annotation != inspect.Signature.empty
Loading