1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
import sys
import pytest
@pytest.fixture(params=["mypy", "pyright"])
def check_typing(pytester, request):
prog = request.param
def f(code):
pytester.makefile(".py", test_something=code)
pytester.makefile(
".toml",
pyproject="""
[tool.pyright]
typeCheckingMode = 'strict'
[tool.mypy]
strict=true
""",
)
result = pytester.run(sys.executable, "-m", prog, "test_something.py")
print(result.stdout)
assert result.ret == 0
yield f
def test_typing_args(check_typing):
check_typing(
"""
from inline_snapshot import snapshot
snapshot([])
snapshot({})
"""
)
def test_typing_call(check_typing):
check_typing(
"""
from inline_snapshot import snapshot,Snapshot
def f(s:Snapshot[int])->None:
assert s==5
f(5)
f(snapshot())
f(snapshot(5))
"""
)
|