Skip to content

Commit f9c6203

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Suppress pyre errors in test cases
Summary: Various test cases have pyre errors that will show up if we make them buck targets. This just suppresses the errors or makes very minimal changes so that they are well typed. Reviewed By: yoney Differential Revision: D87259595 fbshipit-source-id: 77e936fbe466b7a629b709293db9e12d2790bc4c
1 parent 000ef44 commit f9c6203

28 files changed

+81
-4
lines changed

cinderx/PythonLib/test_cinderx/multithreaded_compile_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# pyre-ignore-all-errors
23

34
# This script exercises multi-threaded JIT compilation by importing a bunch of
45
# things and then calling a magic function on the cinderjit module to do a

cinderx/PythonLib/test_cinderx/test___static__/test_enum.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ def test_duplicates(self) -> None:
9191
)
9292

9393
def test_iteration(self) -> None:
94+
# pyre-ignore[6]: Incompatible parameter type
9495
self.assertEqual(set(Shape), {Shape.SQUARE, Shape.CIRCLE})

cinderx/PythonLib/test_cinderx/test___static__/test_native_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ def test_native_lookup(self) -> None:
3131
target = "libc.so.6"
3232
symbol = "labs"
3333

34+
# pyre-ignore[16]: unknown attribute
3435
handle = _ctypes.dlopen(target)
36+
# pyre-ignore[16]: unknown attribute
3537
ctypes_result = _ctypes.dlsym(handle, symbol)
38+
# pyre-ignore[16]: unknown attribute
3639
_ctypes.dlclose(handle)
3740

3841
result = lookup_native_symbol(target, symbol)

cinderx/PythonLib/test_cinderx/test___static__/tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def test_cast_fail(self) -> None:
126126
def test_cast_optional(self) -> None:
127127
self.assertIs(cast(Optional[int], None), None)
128128
self.assertIs(cast(int | None, None), None)
129+
# pyre-ignore[20]: missing arg to __ror__
129130
self.assertIs(cast(None | int, None), None)
130131

131132
def test_cast_generic_type(self) -> None:
@@ -136,14 +137,17 @@ class G(Generic[T]):
136137

137138
g = G()
138139

140+
# pyre-ignore[16]: no attribute __getitem__
139141
self.assertIs(cast(G[int], g), g)
140142

141143
def test_cast_type_too_complex(self) -> None:
142144
with self.assertRaisesRegex(ValueError, r"cast expects type or Optional\[T\]"):
143145
cast(Union[int, str], int)
144146

145147
def test_rand(self) -> None:
148+
# pyre-ignore[16]: no attribute RAND_MAX
146149
self.assertEqual(type(RAND_MAX), int)
150+
# pyre-ignore[16]: no attribute RAND_MAX
147151
self.assertLessEqual(rand(), RAND_MAX)
148152
self.assertGreaterEqual(rand(), 0)
149153

cinderx/PythonLib/test_cinderx/test_asynclazyvalue.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# pyre-ignore-all-errors
23

34
import asyncio
45
import inspect

cinderx/PythonLib/test_cinderx/test_compiler/common.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
)
3030

3131
if sys.version_info >= (3, 14):
32+
# pyre-ignore[21]: unknown imports
3233
from dis import (
3334
_get_code_object,
3435
_make_labels_map,
@@ -85,6 +86,7 @@ def get_disassembly_as_string(self, co: Disassembleable) -> str:
8586
return s.getvalue()
8687

8788
# pyre-ignore[10]: Formatter defined for 3.14+
89+
# pyre-ignore[16]: dis has no Formatter
8890
formatter = Formatter(file=s, offset_width=3)
8991
# pyre-ignore[10]: Formatter defined for 3.14+
9092
bc = Bytecode(co)
@@ -109,6 +111,7 @@ def make_static_instr(
109111
instr[1],
110112
instr.arg,
111113
# pyre-ignore[10]: Formatter defined for 3.14+
114+
# pyre-ignore[16]: dis has no _get_code_object
112115
_get_code_object(co).co_consts[instr.arg],
113116
*instr[4:],
114117
)
@@ -196,8 +199,10 @@ def assertLoadMethodInBytecode(self, x: Disassembleable, name: str) -> None:
196199
def assertBinOpInBytecode(self, x: Disassembleable, binop: str) -> None:
197200
if sys.version_info >= (3, 12):
198201
binop = "NB_" + binop.removeprefix("BINARY_")
202+
# pyre-ignore[21]: unknown _nb_ops
199203
from opcode import _nb_ops
200204

205+
# pyre-ignore[16]: unknown _nb_ops
201206
for i, (name, _sign) in enumerate(_nb_ops):
202207
if name == binop:
203208
self.assertInBytecode(x, "BINARY_OP", i)

cinderx/PythonLib/test_cinderx/test_compiler/compiler_runtest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ def open_with_coding(fname):
4040

4141
codeobj = py_compile(text, sys.argv[1], "exec")
4242

43+
# pyre-ignore[6]: maybe not CodeType
4344
dis_stable.Disassembler().dump_code(codeobj, file=sys.stdout)

cinderx/PythonLib/test_cinderx/test_compiler/test_py37.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# pyre-ignore-all-errors
3+
24
import __future__
35

46
import sys

cinderx/PythonLib/test_cinderx/test_compiler/test_sbs_external.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ def add_test(modname, fname):
4141
def test_external(self) -> None:
4242
with open(fname, "rb") as inp:
4343
encoding, _lines = detect_encoding(inp.readline)
44-
code = b"".join(_lines + inp.readlines()).decode(encoding)
44+
code = b"".join(list(_lines) + inp.readlines()).decode(encoding)
4545
node = ast.parse(code, modname, "exec")
46+
# pyre-ignore[16]: module doesn't have filename
4647
node.filename = modname
4748

4849
orig = compile(node, modname, "exec")
@@ -51,6 +52,7 @@ def test_external(self) -> None:
5152

5253
codeobj = py_compile(node, modname, "exec")
5354
newdump = StringIO()
55+
# pyre-ignore[6]: maybe not CodeType
5456
Disassembler().dump_code(codeobj, newdump)
5557

5658
try:

cinderx/PythonLib/test_cinderx/test_compiler/test_sbs_stdlib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ def test_stdlib(self) -> None:
5858
encoding, _lines = detect_encoding(inp.readline)
5959
except SyntaxError:
6060
return
61-
code = b"".join(_lines + inp.readlines()).decode(encoding)
61+
code = b"".join(list(_lines) + inp.readlines()).decode(encoding)
6262
try:
6363
node = ast.parse(code, modname, "exec")
6464
except SyntaxError:
6565
return
66+
# pyre-ignore[16]: module doesn't have filename
6667
node.filename = modname
6768

6869
try:
@@ -74,6 +75,7 @@ def test_stdlib(self) -> None:
7475

7576
codeobj = py_compile(node, modname, "exec")
7677
newdump = StringIO()
78+
# pyre-ignore[6]: maybe not CodeType
7779
Disassembler().dump_code(codeobj, newdump)
7880

7981
try:

0 commit comments

Comments
 (0)