Skip to content

Commit be0dd60

Browse files
alexmalyshevfacebook-github-bot
authored andcommitted
Add a whole bunch of None return types to Python tests
Summary: Adding the easy ones that don't trigger further pyre errors. This is one of most common gaps in Pyre coverage. Reviewed By: martindemello Differential Revision: D79563390 fbshipit-source-id: fa5a31cc4a2322c95f91f9328ec5caa43f047cb1
1 parent cb2198c commit be0dd60

67 files changed

Lines changed: 1454 additions & 1447 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cinderx/PythonLib/test_cinderx/multithreaded_compile_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ def tearDownClass(cls):
5959
pass
6060

6161
# skip tests that raise errors in JIT preload
62-
def test_load_uninit_module(self):
62+
def test_load_uninit_module(self) -> None:
6363
pass
6464

6565
class StaticRuntimeTests(CompileCaptureOverrides, test_static.StaticRuntimeTests):
6666
# skip tests that raise errors in JIT preload
67-
def test_bad_classloader_type(self):
67+
def test_bad_classloader_type(self) -> None:
6868
pass
6969

7070
suite = unittest.TestLoader().loadTestsFromTestCase(StaticCompilationTests)

cinderx/PythonLib/test_cinderx/test___static__/tests.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@
4747

4848

4949
class StaticTests(unittest.TestCase):
50-
def test_chkdict(self):
50+
def test_chkdict(self) -> None:
5151
tgt = dict if static is None else static.chkdict
5252
self.assertIs(CheckedDict, tgt)
5353
self.assertIs(chkdict, tgt)
5454

55-
def test_pydict(self):
55+
def test_pydict(self) -> None:
5656
self.assertIs(pydict, dict)
5757
self.assertIs(PyDict, Dict)
5858

59-
def test_clen(self):
59+
def test_clen(self) -> None:
6060
self.assertIs(clen, len)
6161

62-
def test_int_types(self):
62+
def test_int_types(self) -> None:
6363
for typ in [
6464
size_t,
6565
ssize_t,
@@ -79,7 +79,7 @@ def test_int_types(self):
7979
x = typ(1)
8080
self.assertEqual(x, 1)
8181

82-
def test_float_types(self):
82+
def test_float_types(self) -> None:
8383
for typ in [
8484
single,
8585
double,
@@ -88,28 +88,28 @@ def test_float_types(self):
8888
x = typ(1.0)
8989
self.assertEqual(x, 1.0)
9090

91-
def test_box(self):
91+
def test_box(self) -> None:
9292
self.assertEqual(box(1), 1)
9393

94-
def test_unbox(self):
94+
def test_unbox(self) -> None:
9595
self.assertEqual(unbox(1), 1)
9696

97-
def test_allow_weakrefs(self):
97+
def test_allow_weakrefs(self) -> None:
9898
class MyClass:
9999
pass
100100

101101
self.assertIs(MyClass, allow_weakrefs(MyClass))
102102

103-
def test_dynamic_return(self):
103+
def test_dynamic_return(self) -> None:
104104
def foo():
105105
pass
106106

107107
self.assertIs(foo, dynamic_return(foo))
108108

109-
def test_cast(self):
109+
def test_cast(self) -> None:
110110
self.assertIs(cast(int, 2), 2)
111111

112-
def test_cast_subtype(self):
112+
def test_cast_subtype(self) -> None:
113113
class Base:
114114
pass
115115

@@ -119,16 +119,16 @@ class Sub(Base):
119119
s = Sub()
120120
self.assertIs(cast(Base, s), s)
121121

122-
def test_cast_fail(self):
122+
def test_cast_fail(self) -> None:
123123
with self.assertRaisesRegex(TypeError, "expected int, got str"):
124124
cast(int, "foo")
125125

126-
def test_cast_optional(self):
126+
def test_cast_optional(self) -> None:
127127
self.assertIs(cast(Optional[int], None), None)
128128
self.assertIs(cast(int | None, None), None)
129129
self.assertIs(cast(None | int, None), None)
130130

131-
def test_cast_generic_type(self):
131+
def test_cast_generic_type(self) -> None:
132132
T = TypeVar("T")
133133

134134
class G(Generic[T]):
@@ -138,11 +138,11 @@ class G(Generic[T]):
138138

139139
self.assertIs(cast(G[int], g), g)
140140

141-
def test_cast_type_too_complex(self):
141+
def test_cast_type_too_complex(self) -> None:
142142
with self.assertRaisesRegex(ValueError, r"cast expects type or Optional\[T\]"):
143143
cast(Union[int, str], int)
144144

145-
def test_rand(self):
145+
def test_rand(self) -> None:
146146
self.assertEqual(type(RAND_MAX), int)
147147
self.assertLessEqual(rand(), RAND_MAX)
148148
self.assertGreaterEqual(rand(), 0)

cinderx/PythonLib/test_cinderx/test_asynclazyvalue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ async def f(idx, res):
232232
self.assertIs(await_stacks[1][1], h1_coro)
233233
self.assertIs(await_stacks[1][2], gatherer_coro)
234234

235-
def test_coro_target_is_bound_method(self):
235+
def test_coro_target_is_bound_method(self) -> None:
236236
class X:
237237
def __init__(self):
238238
self.a = 1
@@ -405,7 +405,7 @@ async def async_cancel(task: asyncio.Task, alv: AsyncLazyValue) -> None:
405405
self.assertEqual(tc_result, None)
406406

407407
@async_test
408-
async def test_throw_1(self):
408+
async def test_throw_1(self) -> None:
409409
async def l0(alv):
410410
return await l1(alv)
411411

0 commit comments

Comments
 (0)