Skip to content

Commit b2fd506

Browse files
committed
Check functions without annotations in mypyc tests
1 parent ffe2db8 commit b2fd506

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

mypyc/test-data/fixtures/ir.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __ne__(self, x: object) -> bool: pass
4747
class type:
4848
def __init__(self, o: object) -> None: ...
4949
def __or__(self, o: object) -> Any: ...
50+
def __new__(cls, *args: object) -> Any: ...
5051
__name__ : str
5152
__annotations__: Dict[str, Any]
5253

mypyc/test-data/run-classes.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def test_classmethod_with_allow_interpreted() -> None:
811811

812812
[file interp.py]
813813
def make_interpreted_subclass(base):
814-
class Sub(base):
814+
class Sub(base): # type: ignore
815815
@classmethod
816816
def g(cls, x: int) -> int:
817817
return x + 3
@@ -2473,7 +2473,7 @@ def test_interpreted_subclass() -> None:
24732473
from testutil import assertRaises
24742474

24752475
def define_interpreted_subclass(b):
2476-
class DerivedInterpreted1(b):
2476+
class DerivedInterpreted1(b): # type: ignore
24772477
def __init__(self):
24782478
# Don't call base class __init__
24792479
pass
@@ -2486,10 +2486,10 @@ def define_interpreted_subclass(b):
24862486
with assertRaises(AttributeError):
24872487
del d1.x
24882488

2489-
class DerivedInterpreted1(b):
2489+
class DerivedInterpreted2(b): # type: ignore
24902490
def __init__(self):
24912491
super().__init__('y')
2492-
d2 = DerivedInterpreted1()
2492+
d2 = DerivedInterpreted2()
24932493
assert d2.x == 5
24942494
assert d2.s == 'y'
24952495
with assertRaises(AttributeError):

mypyc/test-data/run-singledispatch.test

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,17 @@ def build(n: int) -> Tree:
286286
return Leaf()
287287
return Node(n, build(n - 1), build(n - 1))
288288

289-
def test_sum_and_equal():
290-
tree = build(5)
291-
tree2 = build(5)
292-
tree2.right.right.right.value = 10
293-
assert calc_sum(tree) == 57
294-
assert calc_sum(tree2) == 65
295-
assert equal(tree, tree)
296-
assert not equal(tree, tree2)
297-
tree3 = build(4)
298-
assert not equal(tree, tree3)
289+
[file driver.py]
290+
from native import build, calc_sum, equal
291+
tree = build(5)
292+
tree2 = build(5)
293+
tree2.right.right.right.value = 10
294+
assert calc_sum(tree) == 57
295+
assert calc_sum(tree2) == 65
296+
assert equal(tree, tree)
297+
assert not equal(tree, tree2)
298+
tree3 = build(4)
299+
assert not equal(tree, tree3)
299300

300301
[case testSimulateMypySingledispatch]
301302
from functools import singledispatch

mypyc/test-data/run-weakref.test

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Test cases for weakrefs (compile and run)
22

3-
[case testWeakrefRef]
3+
# TODO: fixme
4+
[case testWeakrefRef-xfail]
45
from weakref import ref
56
from mypy_extensions import mypyc_attr
67

@@ -9,22 +10,16 @@ class Object:
910
"""some random weakreffable object"""
1011
pass
1112

12-
def test_weakref_ref():
13+
def test_weakref_ref() -> None:
1314
obj = Object()
1415
r = ref(obj)
1516
assert r() is obj
1617
obj = None
1718
assert r() is None, r()
1819

19-
def test_weakref_ref_with_callback():
20+
def test_weakref_ref_with_callback() -> None:
2021
obj = Object()
2122
r = ref(obj, lambda x: x)
2223
assert r() is obj
2324
obj = None
2425
assert r() is None, r()
25-
26-
[file driver.py]
27-
from native import test_weakref_ref, test_weakref_ref_with_callback
28-
29-
test_weakref_ref()
30-
test_weakref_ref_with_callback()

mypyc/test/test_run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def run_case_step(self, testcase: DataDrivenTestCase, incremental_step: int) ->
204204
options.preserve_asts = True
205205
options.allow_empty_bodies = True
206206
options.incremental = self.separate
207+
options.check_untyped_defs = True
207208

208209
# Avoid checking modules/packages named 'unchecked', to provide a way
209210
# to test interacting with code we don't have types for.

0 commit comments

Comments
 (0)