Skip to content

Commit c1479da

Browse files
committed
more fixes
1 parent 4d2b2b6 commit c1479da

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

whole_repo_tests/revealed_types.py

+18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@
88
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

11+
REVEALED_TYPES = [
12+
("integers()", "int"),
13+
("text()", "str"),
14+
("integers().map(str)", "str"),
15+
("booleans().filter(bool)", "bool"),
16+
("tuples()", "Tuple[()]"),
17+
("tuples(integers())", "Tuple[int]"),
18+
("tuples(integers(), text())", "Tuple[int, str]"),
19+
(
20+
"tuples(integers(), text(), integers(), text(), integers())",
21+
"Tuple[int, str, int, str, int]",
22+
),
23+
(
24+
"tuples(text(), text(), text(), text(), text(), text())",
25+
"Tuple[Any, ...]",
26+
),
27+
]
28+
1129
NUMPY_REVEALED_TYPES = [
1230
(
1331
'arrays(dtype=np.dtype("int32"), shape=1)',

whole_repo_tests/test_mypy.py

+2-17
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from hypothesistooling.projects.hypothesispython import PYTHON_SRC
1717
from hypothesistooling.scripts import pip_tool, tool_path
1818

19-
from .revealed_types import NUMPY_REVEALED_TYPES
19+
from .revealed_types import NUMPY_REVEALED_TYPES, REVEALED_TYPES
2020

2121
PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"]
2222

@@ -99,12 +99,8 @@ def convert_lines():
9999
@pytest.mark.parametrize(
100100
"val,expect",
101101
[
102-
("integers()", "int"),
103-
("text()", "str"),
104-
("integers().map(str)", "str"),
105-
("booleans().filter(bool)", "bool"),
102+
*REVEALED_TYPES, # shared with Pyright
106103
("lists(none())", "list[None]"),
107-
("dictionaries(integers(), datetimes())", "dict[int, datetime.datetime]"),
108104
("data()", "hypothesis.strategies._internal.core.DataObject"),
109105
("none() | integers()", "Union[None, int]"),
110106
("recursive(integers(), lists)", "Union[list[Any], int]"),
@@ -119,17 +115,6 @@ def convert_lines():
119115
"one_of(integers(), text(), none(), binary(), builds(list), builds(dict))",
120116
"Any",
121117
),
122-
("tuples()", "tuple[()]"),
123-
("tuples(integers())", "tuple[int]"),
124-
("tuples(integers(), text())", "tuple[int, str]"),
125-
(
126-
"tuples(integers(), text(), integers(), text(), integers())",
127-
"tuple[int, str, int, str, int]",
128-
),
129-
(
130-
"tuples(text(), text(), text(), text(), text(), text())",
131-
"tuple[Any, ...]",
132-
),
133118
# Note: keep this in sync with the equivalent test for Pyright
134119
],
135120
)

whole_repo_tests/test_pyright.py

+2-16
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from hypothesistooling.projects.hypothesispython import HYPOTHESIS_PYTHON, PYTHON_SRC
2424
from hypothesistooling.scripts import pip_tool, tool_path
2525

26-
from .revealed_types import NUMPY_REVEALED_TYPES
26+
from .revealed_types import NUMPY_REVEALED_TYPES, REVEALED_TYPES
2727

2828
PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
2929

@@ -178,10 +178,7 @@ def test_numpy_arrays_strategy(tmp_path: Path):
178178
@pytest.mark.parametrize(
179179
"val,expect",
180180
[
181-
("integers()", "int"),
182-
("text()", "str"),
183-
("integers().map(str)", "str"),
184-
("booleans().filter(bool)", "bool"),
181+
*REVEALED_TYPES, # shared with Mypy
185182
("lists(none())", "List[None]"),
186183
("dictionaries(integers(), datetimes())", "Dict[int, datetime]"),
187184
("data()", "DataObject"),
@@ -198,17 +195,6 @@ def test_numpy_arrays_strategy(tmp_path: Path):
198195
"one_of(integers(), text(), none(), binary(), builds(list), builds(dict))",
199196
"Any",
200197
),
201-
("tuples()", "Tuple[()]"),
202-
("tuples(integers())", "Tuple[int]"),
203-
("tuples(integers(), text())", "Tuple[int, str]"),
204-
(
205-
"tuples(integers(), text(), integers(), text(), integers())",
206-
"Tuple[int, str, int, str, int]",
207-
),
208-
(
209-
"tuples(text(), text(), text(), text(), text(), text())",
210-
"Tuple[Any, ...]",
211-
),
212198
# Note: keep this in sync with the equivalent test for Mypy
213199
],
214200
)

0 commit comments

Comments
 (0)