8000 Remove force_uppercase_builtins default from test helpers (#19173) · python/mypy@409d294 · GitHub
[go: up one dir, main page]

Skip to content

Commit 409d294

Browse files
authored
Remove force_uppercase_builtins default from test helpers (#19173)
Mypy only supports Python 3.9+. Update the tests to use lowercase names for PEP 585 generics in error messages. A followup can consider deprecating `--force-uppercase-builtins` and making it a no-op.
1 parent 95a09c8 commit 409d294

File tree

88 files changed

+1617
-1632
lines changed

Some content is hidden

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

88 files changed

+1617
-1632
lines changed

mypy/test/helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,12 @@ def local_sys_path_set() -> Iterator[None]:
258258

259259

260260
def testfile_pyversion(path: str) -> tuple[int, int]:
261-
m = re.search(r"python3([0-9]+)\.test$", path)
262-
if m:
263-
return 3, int(m.group(1))
261+
if m := re.search(r"python3([0-9]+)\.test$", path):
262+
# For older unsupported version like python38,
263+
# default to that earliest supported version.
264+
return max((3, int(m.group(1))), defaults.PYTHON3_VERSION_MIN)
264265
else:
265-
return defaults.PYTHON3_VERSION
266+
return defaults.PYTHON3_VERSION_MIN
266267

267268

268269
def normalize_error_messages(messages: list[str]) -> list[str]:
@@ -353,7 +354,6 @@ def parse_options(
353354
options = Options()
354355
options.error_summary = False
355356
options.hide_error_codes = True
356-
options.force_uppercase_builtins = True
357357
options.force_union_syntax = True
358358

359359
# Allow custom python version to override testfile_pyversion.

mypy/test/testcheck.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ def run_case_once(
136136
options.hide_error_codes = False
137137
if "abstract" not in testcase.file:
138138
options.allow_empty_bodies = not testcase.name.endswith("_no_empty")
139-
if "lowercase" not in testcase.file:
140-
options.force_uppercase_builtins = True
141139
if "union-error" not in testcase.file:
142140
options.force_union_syntax = True
143141

mypy/test/testcmdline.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ def test_python_cmdline(testcase: DataDrivenTestCase, step: int) -> None:
6161
args.append("--hide-error-codes")
6262
if "--disallow-empty-bodies" not in args:
6363
args.append("--allow-empty-bodies")
64-
if "--no-force-uppercase-builtins" not in args:
65-
args.append("--force-uppercase-builtins")
6664
if "--no-force-union-syntax" not in args:
6765
args.append("--force-union-syntax")
6866
# Type check the program.

mypy/test/testmerge.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ def build(self, source: str, testcase: DataDrivenTestCase) -> BuildResult | None
102102
options.export_types = True
103103
options.show_traceback = True
104104
options.allow_empty_bodies = True
105-
options.force_uppercase_builtins = True
106105
main_path = os.path.join(test_temp_dir, "main")
107106

108107
self.str_conv.options = options

mypy/test/testparse.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def test_parser(testcase: DataDrivenTestCase) -> None:
3838
The argument contains the description of the test case.
3939
"""
4040
options = Options()
41-
options.force_uppercase_builtins = True
4241
options.hide_error_codes = True
4342

4443
if testcase.file.endswith("python310.test"):

mypy/test/testpythoneval.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def test_python_evaluation(testcase: DataDrivenTestCase, cache_dir: str) -> None
5252
"--no-error-summary",
5353
"--hide-error-codes",
5454
"--allow-empty-bodies",
55-
"--force-uppercase-builtins",
5655
"--test-env", # Speeds up some checks
5756
]
5857
interpreter = python3_path

mypy/test/testsemanal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def get_semanal_options(program_text: str, testcase: DataDrivenTestCase) -> Opti
4444
options.semantic_analysis_only = True
4545
options.show_traceback = True
4646
options.python_version = PYTHON3_VERSION
47-
options.force_uppercase_builtins = True
4847
return options
4948

5049

mypy/test/testtransform.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def test_transform(testcase: DataDrivenTestCase) -> None:
3838
options.use_builtins_fixtures = True
3939
options.semantic_analysis_only = True
4040
options.show_traceback = True
41-
options.force_uppercase_builtins = True
4241
result = build.build(
4342
sources=[BuildSource("main", None, src)], options=options, alt_lib_path=test_temp_dir
4443
)

mypy/test/testtypegen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def run_case(self, testcase: DataDrivenTestCase) -> None:
3535
options.export_types = True
3636
options.preserve_asts = True
3737
options.allow_empty_bodies = True
38-
options.force_uppercase_builtins = True
3938
result = build.build(
4039
sources=[BuildSource("main", None, src)],
4140
options=options,

mypy/test/testtypes.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
Expression,
2424
NameExpr,
2525
)
26-
from mypy.options import Options
2726
from mypy.plugins.common import find_shallow_matching_overload_item
2827
from mypy.state import state
2928
from mypy.subtypes import is_more_precise, is_proper_subtype, is_same_type, is_subtype
@@ -130,17 +129,13 @@ def test_callable_type_with_var_args(self) -> None:
130129
)
131130
assert_equal(str(c3), "def (X? =, *Y?) -> Any")
132131

133-
def test_tuple_type_upper(self) -> None:
134-
options = Options()
135-
options.force_uppercase_builtins = True
136-
assert_equal(TupleType([], self.fx.std_tuple).str_with_options(options), "Tuple[()]")
137-
assert_equal(TupleType([self.x], self.fx.std_tuple).str_with_options(options), "Tuple[X?]")
138-
assert_equal(
139-
TupleType(
140-
[self.x, AnyType(TypeOfAny.special_form)], self.fx.std_tuple
141-
).str_with_options(options),
142-
"Tuple[X?, Any]",
143-
)
132+
def test_tuple_type_str(self) -> None:
133+
t1 = TupleType([], self.fx.std_tuple)
134+
assert_equal(str(t1), "tuple[()]")
135+
t2 = TupleType([self.x], self.fx.std_tuple)
136+
assert_equal(str(t2), "tuple[X?]")
137+
t3 = TupleType([self.x, AnyType(TypeOfAny.special_form)], self.fx.std_tuple)
138+
assert_equal(str(t3), "tuple[X?, Any]")
144139

145140
def test_type_variable_binding(self) -> None:
146141
assert_equal(

0 commit comments

Comments
 (0)
0