diff --git a/mypy/messages.py b/mypy/messages.py index ae8673ad93bf..03062a9d3de4 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -2970,11 +2970,20 @@ def [T <: int] f(self, x: int, y: T) -> None if tp.arg_kinds[i] == ARG_STAR2: s += "**" name = tp.arg_names[i] + if not name and not options.reveal_verbose_types: + # Avoid ambiguous (and weird) formatting for anonymous args/kwargs. + if tp.arg_kinds[i] == ARG_STAR and isinstance(tp.arg_types[i], UnpackType): + name = "args" + elif tp.arg_kinds[i] == ARG_STAR2 and tp.unpack_kwargs: + name = "kwargs" if name: s += name + ": " type_str = format_type_bare(tp.arg_types[i], options) if tp.arg_kinds[i] == ARG_STAR2 and tp.unpack_kwargs: - type_str = f"Unpack[{type_str}]" + if options.reveal_verbose_types: + type_str = f"Unpack[{type_str}]" + else: + type_str = f"**{type_str}" s += type_str if tp.arg_kinds[i].is_optional(): s += " = ..." diff --git a/mypy/options.py b/mypy/options.py index c63e74b22c4d..db70a1d5fc83 100644 --- a/mypy/options.py +++ b/mypy/options.py @@ -372,6 +372,8 @@ def __init__(self) -> None: self.show_error_end: bool = False self.hide_error_codes = False self.show_error_code_links = False + # This is an internal-only flag to simplify migrating test output. + self.reveal_verbose_types = False # Use soft word wrap and show trimmed source snippets with error location markers. self.pretty = False self.dump_graph = False @@ -433,7 +435,7 @@ def __init__(self) -> None: self.mypyc_skip_c_generation = False def use_star_unpack(self) -> bool: - return self.python_version >= (3, 11) + return self.python_version >= (3, 11) or not self.reveal_verbose_types def snapshot(self) -> dict[str, object]: """Produce a comparable snapshot of this Option""" diff --git a/mypy/semanal.py b/mypy/semanal.py index e2c073fd4dea..952a5819a442 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -292,6 +292,7 @@ TypeAliasType, TypedDictType, TypeOfAny, + TypeStrVisitor, TypeType, TypeVarId, TypeVarLikeType, @@ -1376,7 +1377,7 @@ def process_deprecated_overload(self, defn: OverloadedFuncDef) -> None: elif (deprecated := self.get_deprecated(d)) is not None: deprecation = True if isinstance(typ := item.func.type, CallableType): - typestr = f" {typ} " + typestr = f" {typ.accept(TypeStrVisitor(options=self.options))} " else: typestr = " " item.func.deprecated = ( diff --git a/mypy/test/testcheck.py b/mypy/test/testcheck.py index 3326d642c6a4..54cdb38596bf 100644 --- a/mypy/test/testcheck.py +++ b/mypy/test/testcheck.py @@ -137,6 +137,7 @@ def run_case_once( options.use_builtins_fixtures = True options.show_traceback = True options.native_parser = bool(os.environ.get("TEST_NATIVE_PARSER")) + options.reveal_verbose_types = not testcase.name.endswith("_no_verbose_reveal") if options.num_workers: options.fixed_format_cache = True diff --git a/mypy/test/testfinegrained.py b/mypy/test/testfinegrained.py index b098c1fb0ad2..8a93018e39b3 100644 --- a/mypy/test/testfinegrained.py +++ b/mypy/test/testfinegrained.py @@ -155,6 +155,7 @@ def get_options(self, source: str, testcase: DataDrivenTestCase, build_cache: bo options.export_types = "inspect" in testcase.file # Treat empty bodies safely for these test cases. options.allow_empty_bodies = not testcase.name.endswith("_no_empty") + options.reveal_verbose_types = True if re.search("flags:.*--follow-imports", source) is None: # Override the default for follow_imports options.follow_imports = "error" diff --git a/mypy/test/testmerge.py b/mypy/test/testmerge.py index c2c75f60be29..2e88b519f7f8 100644 --- a/mypy/test/testmerge.py +++ b/mypy/test/testmerge.py @@ -102,6 +102,7 @@ def build(self, source: str, testcase: DataDrivenTestCase) -> BuildResult | None options.export_types = True options.show_traceback = True options.allow_empty_bodies = True + options.reveal_verbose_types = True main_path = os.path.join(test_temp_dir, "main") self.str_conv.options = options @@ -222,7 +223,8 @@ def dump_types( key=lambda n: ( n.line, short_type(n), - n.str_with_options(self.str_conv.options) + str(type_map[n]), + n.str_with_options(self.str_conv.options) + + type_map[n].accept(self.type_str_conv), ), ): typ = type_map[expr] diff --git a/mypy/test/testsemanal.py b/mypy/test/testsemanal.py index 11cd36c83fd7..e11a25617fa4 100644 --- a/mypy/test/testsemanal.py +++ b/mypy/test/testsemanal.py @@ -8,6 +8,7 @@ from mypy.modulefinder import BuildSource from mypy.nodes import TypeInfo from mypy.options import Options +from mypy.strconv import StrConv from mypy.test.config import test_temp_dir from mypy.test.data import DataDrivenTestCase, DataSuite from mypy.test.helpers import ( @@ -19,8 +20,9 @@ ) # Semantic analyzer test cases: dump parse tree - # Semantic analysis test case description files. +from mypy.types import TypeStrVisitor + semanal_files = find_test_files( pattern="semanal-*.test", exclude=[ @@ -38,6 +40,7 @@ def get_semanal_options(program_text: str, testcase: DataDrivenTestCase) -> Opti options.semantic_analysis_only = True options.show_traceback = True options.python_version = PYTHON3_VERSION + options.reveal_verbose_types = True return options @@ -154,14 +157,22 @@ class SemAnalTypeInfoSuite(DataSuite): required_out_section = True files = ["semanal-typeinfo.test"] + def setup(self) -> None: + super().setup() + self.str_conv = StrConv(options=Options()) + self.type_str_conv = TypeStrVisitor(options=Options()) + def run_case(self, testcase: DataDrivenTestCase) -> None: """Perform a test case.""" + src = "\n".join(testcase.input) + options = get_semanal_options(src, testcase) + self.str_conv.options = options + self.type_str_conv.options = options try: # Build test case input. - src = "\n".join(testcase.input) result = build.build( sources=[BuildSource("main", None, src)], - options=get_semanal_options(src, testcase), + options=options, alt_lib_path=test_temp_dir, ) a = result.errors @@ -179,7 +190,7 @@ def run_case(self, testcase: DataDrivenTestCase) -> None: typeinfos[n.fullname] = n.node # The output is the symbol table converted into a string. - a = str(typeinfos).split("\n") + a = typeinfos.dump(self.str_conv, self.type_str_conv).split("\n") except CompileError as e: a = e.messages assert_string_arrays_equal( @@ -190,10 +201,10 @@ def run_case(self, testcase: DataDrivenTestCase) -> None: class TypeInfoMap(dict[str, TypeInfo]): - def __str__(self) -> str: + def dump(self, str_conv: StrConv, type_str_conv: TypeStrVisitor) -> str: a: list[str] = ["TypeInfoMap("] for x, y in sorted(self.items()): - ti = ("\n" + " ").join(str(y).split("\n")) + ti = ("\n" + " ").join(y.dump(str_conv, type_str_conv).split("\n")) a.append(f" {x} : {ti}") a[-1] += ")" return "\n".join(a) diff --git a/mypy/test/teststubtest.py b/mypy/test/teststubtest.py index 4023a191b548..faf61952df66 100644 --- a/mypy/test/teststubtest.py +++ b/mypy/test/teststubtest.py @@ -2756,7 +2756,7 @@ def test_output(self) -> None: f'error: {TEST_MODULE_NAME}.bad is inconsistent, stub parameter "number" differs ' 'from runtime parameter "num"\n' f"Stub: in file {TEST_MODULE_NAME}.pyi:1\n" - "def (number: builtins.int, text: builtins.str)\n" + "def (number: int, text: str)\n" f"Runtime: in file {TEST_MODULE_NAME}.py:1\ndef (num, text)\n\n" "Found 1 error (checked 1 module)\n" ) @@ -2951,7 +2951,7 @@ def myfunction(arg: str, /) -> None: ... stub = result.files["__main__"].names["myfunction"].node assert isinstance(stub, nodes.OverloadedFuncDef) sig = mypy.stubtest.Signature.from_overloadedfuncdef(stub) - assert str(sig) == "def (arg: builtins.int | builtins.str)" + assert str(sig) == "def (arg: int | str)" def test_config_file(self) -> None: runtime = "temp = 5\n" diff --git a/mypy/test/testtransform.py b/mypy/test/testtransform.py index 48a3eeed2115..10875a951fb4 100644 --- a/mypy/test/testtransform.py +++ b/mypy/test/testtransform.py @@ -38,6 +38,7 @@ def test_transform(testcase: DataDrivenTestCase) -> None: options.use_builtins_fixtures = True options.semantic_analysis_only = True options.show_traceback = True + options.reveal_verbose_types = True result = build.build( sources=[BuildSource("main", None, src)], options=options, alt_lib_path=test_temp_dir ) diff --git a/mypy/test/testtypegen.py b/mypy/test/testtypegen.py index 42d831beeecc..cae2f0e0fd01 100644 --- a/mypy/test/testtypegen.py +++ b/mypy/test/testtypegen.py @@ -35,6 +35,7 @@ def run_case(self, testcase: DataDrivenTestCase) -> None: options.export_types = True options.preserve_asts = True options.allow_empty_bodies = True + options.reveal_verbose_types = True result = build.build( sources=[BuildSource("main", None, src)], options=options, diff --git a/mypy/test/testtypes.py b/mypy/test/testtypes.py index 090796ec9f44..6562f541d73b 100644 --- a/mypy/test/testtypes.py +++ b/mypy/test/testtypes.py @@ -144,7 +144,7 @@ def test_type_variable_binding(self) -> None: "X", "X", TypeVarId(1), [], self.fx.o, AnyType(TypeOfAny.from_omitted_generics) ) ), - "X`1", + "X", ) assert_equal( str( @@ -157,7 +157,7 @@ def test_type_variable_binding(self) -> None: AnyType(TypeOfAny.from_omitted_generics), ) ), - "X`1", + "X", ) def test_generic_function_type(self) -> None: diff --git a/mypy/types.py b/mypy/types.py index c3e12c720161..d5462422d183 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -3741,12 +3741,16 @@ def visit_deleted_type(self, t: DeletedType, /) -> str: return f"" def visit_instance(self, t: Instance, /) -> str: + fullname = t.type.fullname + if not self.options.reveal_verbose_types and fullname.startswith("builtins."): + fullname = t.type.name if t.last_known_value and not t.args: # Instances with a literal fallback should never be generic. If they are, # something went wrong so we fall back to showing the full Instance repr. s = f"{t.last_known_value.accept(self)}?" + else: - s = t.type.fullname or t.type.name or "" + s = fullname or t.type.name or "" if t.args: if t.type.fullname == "builtins.tuple": @@ -3761,10 +3765,13 @@ def visit_instance(self, t: Instance, /) -> str: return s def visit_type_var(self, t: TypeVarType, /) -> str: - s = f"{t.name}`{t.id}" + if not self.options.reveal_verbose_types: + s = t.name + else: + s = f"{t.name}`{t.id}" if self.id_mapper and t.upper_bound: s += f"(upper_bound={t.upper_bound.accept(self)})" - if t.has_default(): + if t.has_default() and self.options.reveal_verbose_types: s += f" = {t.default.accept(self)}" return s @@ -3773,10 +3780,13 @@ def visit_param_spec(self, t: ParamSpecType, /) -> str: s = "" if t.prefix.arg_types: s += f"[{self.list_str(t.prefix.arg_types)}, **" - s += f"{t.name_with_suffix()}`{t.id}" + if not self.options.reveal_verbose_types: + s += t.name_with_suffix() + else: + s += f"{t.name_with_suffix()}`{t.id}" if t.prefix.arg_types: s += "]" - if t.has_default(): + if t.has_default() and self.options.reveal_verbose_types: s += f" = {t.default.accept(self)}" return s @@ -3810,8 +3820,11 @@ def visit_parameters(self, t: Parameters, /) -> str: return f"[{s}]" def visit_type_var_tuple(self, t: TypeVarTupleType, /) -> str: - s = f"{t.name}`{t.id}" - if t.has_default(): + if not self.options.reveal_verbose_types: + s = t.name + else: + s = f"{t.name}`{t.id}" + if t.has_default() and self.options.reveal_verbose_types: s += f" = {t.default.accept(self)}" return s @@ -3836,11 +3849,20 @@ def visit_callable_type(self, t: CallableType, /) -> str: if t.arg_kinds[i] == ARG_STAR2: s += "**" name = t.arg_names[i] + if not name and not self.options.reveal_verbose_types: + # Avoid ambiguous (and weird) formatting for anonymous args/kwargs. + if t.arg_kinds[i] == ARG_STAR and isinstance(t.arg_types[i], UnpackType): + name = "args" + elif t.arg_kinds[i] == ARG_STAR2 and t.unpack_kwargs: + name = "kwargs" if name: s += name + ": " type_str = t.arg_types[i].accept(self) if t.arg_kinds[i] == ARG_STAR2 and t.unpack_kwargs: - type_str = f"Unpack[{type_str}]" + if not self.options.reveal_verbose_types: + type_str = f"**{type_str}" + else: + type_str = f"Unpack[{type_str}]" s += type_str if t.arg_kinds[i].is_optional(): s += " =" @@ -3867,7 +3889,6 @@ def visit_callable_type(self, t: CallableType, /) -> str: vs = [] for var in t.variables: if isinstance(var, TypeVarType): - # We reimplement TypeVarType.__repr__ here in order to support id_mapper. if var.values: vals = f"({', '.join(val.accept(self) for val in var.values)})" vs.append(f"{var.name} in {vals}") @@ -3919,7 +3940,10 @@ def item_str(name: str, typ: str) -> str: prefix = "" if t.fallback and t.fallback.type: if t.fallback.type.fullname not in TPDICT_FB_NAMES: - prefix = repr(t.fallback.type.fullname) + ", " + if not self.options.reveal_verbose_types: + prefix = t.fallback.type.fullname + ", " + else: + prefix = repr(t.fallback.type.fullname) + ", " return f"TypedDict({prefix}{s})" def visit_raw_expression_type(self, t: RawExpressionType, /) -> str: @@ -3970,6 +3994,8 @@ def visit_type_alias_type(self, t: TypeAliasType, /) -> str: return type_str def visit_unpack_type(self, t: UnpackType, /) -> str: + if not self.options.reveal_verbose_types: + return f"*{t.type.accept(self)}" return f"Unpack[{t.type.accept(self)}]" def list_str(self, a: Iterable[Type], *, use_or_syntax: bool = False) -> str: diff --git a/test-data/unit/check-flags.test b/test-data/unit/check-flags.test index 5e9c7f4be8dc..9a5ed6c07e6e 100644 --- a/test-data/unit/check-flags.test +++ b/test-data/unit/check-flags.test @@ -2737,3 +2737,31 @@ def f() -> None: [file mypy.ini] \[mypy] disallow_redefinition = true + +[case testRevealSimpleTypes_no_verbose_reveal] +from typing import Generic, TypeVar, Callable +from typing_extensions import TypeVarTuple, Unpack, TypedDict + +T = TypeVar("T", bound=int) +S = TypeVar("S", default=list[T]) + +class A(Generic[T, S]): ... +reveal_type(A) # N: Revealed type is "def [T <: int, S = list[T]] () -> __main__.A[T, S]" + +Ts = TypeVarTuple("Ts") +def foo(x: int, *xs: Unpack[Ts]) -> tuple[int, Unpack[Ts]]: ... +reveal_type(foo) # N: Revealed type is "def [Ts] (x: int, *xs: *Ts) -> tuple[int, *Ts]" + +class User(TypedDict): + age: int + name: str + +def bar(x: int, **kwargs: Unpack[User]) -> None: ... +reveal_type(bar) # N: Revealed type is "def (x: int, **kwargs: **TypedDict(__main__.User, {'age': int, 'name': str}))" + +fn: Callable[[Unpack[Ts], Unpack[User]], tuple[Unpack[Ts]]] +reveal_type(fn) # N: Revealed type is "def [Ts] (*args: *Ts, **kwargs: **TypedDict(__main__.User, {'age': int, 'name': str})) -> tuple[*Ts]" + +fx: Callable[[int, Unpack[Ts], int], tuple[Unpack[Ts]]] +reveal_type(fx) # N: Revealed type is "def [Ts] (int, *args: *tuple[*Ts, int]) -> tuple[*Ts]" +[builtins fixtures/tuple.pyi] diff --git a/test-data/unit/check-typevar-tuple.test b/test-data/unit/check-typevar-tuple.test index 874c79df0e19..703653227e20 100644 --- a/test-data/unit/check-typevar-tuple.test +++ b/test-data/unit/check-typevar-tuple.test @@ -2432,7 +2432,7 @@ reveal_type(test) # N: Revealed type is "def [Ts] (*args: Unpack[Ts`-1]) -> __m reveal_type(test(1, 2, 3)) # N: Revealed type is "__main__.CM[tuple[Literal[1]?, Literal[2]?, Literal[3]?]]" [builtins fixtures/tuple.pyi] -[case testTypeVarTupleAgainstParamSpecActualFailedNoCrash] +[case testTypeVarTupleAgainstParamSpecActualFailedNoCrash_no_verbose_reveal] from typing import Generic, TypeVar, TypeVarTuple, Unpack, Callable, Tuple, List from typing_extensions import ParamSpec @@ -2443,7 +2443,7 @@ class CM(Generic[R]): ... def cm(fn: Callable[P, List[R]]) -> Callable[P, CM[R]]: ... Ts = TypeVarTuple("Ts") -@cm # E: Argument 1 to "cm" has incompatible type "def [Ts`-1] test(*args: Unpack[Ts]) -> tuple[Unpack[Ts]]"; expected "def (*args: Never) -> list[Never]" +@cm # E: Argument 1 to "cm" has incompatible type "def [Ts] test(*args: *Ts) -> tuple[*Ts]"; expected "def (*args: Never) -> list[Never]" def test(*args: Unpack[Ts]) -> Tuple[Unpack[Ts]]: ... reveal_type(test) # N: Revealed type is "def (*args: Never) -> __main__.CM[Never]" @@ -2719,7 +2719,7 @@ x: MyTuple[int, str] reveal_type(x[0]) # N: Revealed type is "Any" [builtins fixtures/tuple.pyi] -[case testHigherOrderFunctionUnpackTypeVarTupleViaParamSpec] +[case testHigherOrderFunctionUnpackTypeVarTupleViaParamSpec_no_verbose_reveal] from typing import Callable, ParamSpec, TypeVar, TypeVarTuple, Unpack P = ParamSpec("P") @@ -2739,7 +2739,7 @@ def foo() -> str: # this is a false positive, but it no longer crashes -call(run, foo, some_kwarg="a") # E: Argument 1 to "call" has incompatible type "def [Ts`-1, T] run(func: def (*Unpack[Ts]) -> T, *args: Unpack[Ts], some_kwarg: str = ...) -> T"; expected "Callable[[Callable[[], str], str], str]" +call(run, foo, some_kwarg="a") # E: Argument 1 to "call" has incompatible type "def [Ts, T] run(func: def (*args: *Ts) -> T, *args: *Ts, some_kwarg: str = ...) -> T"; expected "Callable[[Callable[[], str], str], str]" [builtins fixtures/tuple.pyi] [case testTypeVarTuplePassedParameters] diff --git a/test-data/unit/cmdline.test b/test-data/unit/cmdline.test index ba1589dfb1c6..2a314afff04e 100644 --- a/test-data/unit/cmdline.test +++ b/test-data/unit/cmdline.test @@ -403,13 +403,13 @@ reveal_type(a.__pow__(2)) reveal_type(a.__pow__(a)) [out] int_pow.py:3: note: Revealed type is "Literal[1]" -int_pow.py:4: note: Revealed type is "builtins.int" -int_pow.py:5: note: Revealed type is "builtins.int" +int_pow.py:4: note: Revealed type is "int" +int_pow.py:5: note: Revealed type is "int" int_pow.py:6: note: Revealed type is "Literal[1]" -int_pow.py:7: note: Revealed type is "builtins.float" -int_pow.py:8: note: Revealed type is "builtins.float" +int_pow.py:7: note: Revealed type is "float" +int_pow.py:8: note: Revealed type is "float" int_pow.py:9: note: Revealed type is "Any" -int_pow.py:10: note: Revealed type is "builtins.int" +int_pow.py:10: note: Revealed type is "int" int_pow.py:11: note: Revealed type is "Any" == Return code: 0 diff --git a/test-data/unit/errorstream.test b/test-data/unit/errorstream.test index 46af433f8916..67af910c582c 100644 --- a/test-data/unit/errorstream.test +++ b/test-data/unit/errorstream.test @@ -47,8 +47,8 @@ x = 1 + int() [out] ==== Errors flushed ==== -b.py:3: note: Revealed type is "builtins.int" +b.py:3: note: Revealed type is "int" b.py:5: error: Unsupported operand types for / ("int" and "str") ==== Errors flushed ==== a.py:2: error: Unsupported operand types for + ("int" and "str") -a.py:4: note: Revealed type is "builtins.int" +a.py:4: note: Revealed type is "int" diff --git a/test-data/unit/native-parser.test b/test-data/unit/native-parser.test index b9c2e3fe0939..8d7d53485e84 100644 --- a/test-data/unit/native-parser.test +++ b/test-data/unit/native-parser.test @@ -2023,7 +2023,7 @@ def f(*args: *Ts) -> None: MypyFile:1( FuncDef:1( f - def (*args: Unpack[Ts?]) -> None? + def (*args: *Ts?) -> None? VarArg( Var(args)) Block:2( @@ -2037,7 +2037,7 @@ MypyFile:1( NameExpr(x) TempNode:1( Any) - tuple?[int?, Unpack[Ts?], str?])) + tuple?[int?, *Ts?, str?])) [case testLiteralStringType] diff --git a/test-data/unit/outputjson.test b/test-data/unit/outputjson.test index 51a49c64530a..39741b3d1a8b 100644 --- a/test-data/unit/outputjson.test +++ b/test-data/unit/outputjson.test @@ -39,6 +39,6 @@ foo('42') def bar() -> None: ... bar('42') [out] -{"file": "main", "line": 12, "column": 12, "end_line": 12, "end_column": 15, "message": "Revealed type is \"Overload(def (), def (x: builtins.int))\"", "hint": null, "code": "misc", "severity": "note"} +{"file": "main", "line": 12, "column": 12, "end_line": 12, "end_column": 15, "message": "Revealed type is \"Overload(def (), def (x: int))\"", "hint": null, "code": "misc", "severity": "note"} {"file": "main", "line": 14, "column": 0, "end_line": 14, "end_column": 9, "message": "No overload variant of \"foo\" matches argument type \"str\"", "hint": "Possible overload variants:\n def foo() -> None\n def foo(x: int) -> None", "code": "call-overload", "severity": "error"} {"file": "main", "line": 17, "column": 0, "end_line": 17, "end_column": 9, "message": "Too many arguments for \"bar\"", "hint": null, "code": "call-arg", "severity": "error"} diff --git a/test-data/unit/parse-python313.test b/test-data/unit/parse-python313.test index efbafb0766f5..0a7efcd45ff1 100644 --- a/test-data/unit/parse-python313.test +++ b/test-data/unit/parse-python313.test @@ -68,7 +68,7 @@ MypyFile:1( TypeParam( *Ts Default( - Unpack[tuple?[str?, int?]])) + *tuple?[str?, int?])) Block:1( PassStmt:1())) ClassDef:2( @@ -76,5 +76,5 @@ MypyFile:1( TypeParam( *Ts Default( - Unpack[tuple?[str?, int?]])) + *tuple?[str?, int?])) PassStmt:2())) diff --git a/test-data/unit/pep561.test b/test-data/unit/pep561.test index fe791a16d555..a913dacc37e0 100644 --- a/test-data/unit/pep561.test +++ b/test-data/unit/pep561.test @@ -18,7 +18,7 @@ from typedpkg import dne a = ex(['']) reveal_type(a) [out] -testTypedPkgSimple.py:5: note: Revealed type is "builtins.tuple[builtins.str, ...]" +testTypedPkgSimple.py:5: note: Revealed type is "tuple[str, ...]" [case testTypedPkgSimplePackageSearchPath] # pkgs: typedpkg @@ -61,7 +61,7 @@ a = ex(['']) reveal_type(a) [out] testTypedPkgStubs.py:3: error: Module "typedpkg" has no attribute "dne" -testTypedPkgStubs.py:5: note: Revealed type is "builtins.list[builtins.str]" +testTypedPkgStubs.py:5: note: Revealed type is "list[str]" [case testStubPrecedence] # pkgs: typedpkg, typedpkg-stubs @@ -70,7 +70,7 @@ from typedpkg import dne a = ex(['']) reveal_type(a) [out] -testStubPrecedence.py:5: note: Revealed type is "builtins.list[builtins.str]" +testStubPrecedence.py:5: note: Revealed type is "list[str]" [case testTypedPkgSimpleEditable] # pkgs: typedpkg; editable @@ -79,7 +79,7 @@ from typedpkg import dne a = ex(['']) reveal_type(a) [out] -testTypedPkgSimpleEditable.py:5: note: Revealed type is "builtins.tuple[builtins.str, ...]" +testTypedPkgSimpleEditable.py:5: note: Revealed type is "tuple[str, ...]" [case testTypedPkgNamespaceImportFrom] # pkgs: typedpkg, typedpkg_ns_a diff --git a/test-data/unit/pythoneval-asyncio.test b/test-data/unit/pythoneval-asyncio.test index e1f0f861eef3..e4c416ff71b2 100644 --- a/test-data/unit/pythoneval-asyncio.test +++ b/test-data/unit/pythoneval-asyncio.test @@ -474,7 +474,7 @@ def test() -> None: async def bad(arg: P) -> T: pass [out] -_program.py:8: note: Revealed type is "def [T] (arg: P?) -> typing.Coroutine[Any, Any, T`-1]" +_program.py:8: note: Revealed type is "def [T] (arg: P?) -> typing.Coroutine[Any, Any, T]" _program.py:9: error: Value of type "Coroutine[Any, Any, Never]" must be used _program.py:9: note: Are you missing an await? _program.py:11: error: Variable "_testForwardRefToBadAsyncShouldNotCrash_newsemanal.P" is not valid as a type diff --git a/test-data/unit/pythoneval.test b/test-data/unit/pythoneval.test index 7d5e0ef1cdfd..2d3f867d8dfd 100644 --- a/test-data/unit/pythoneval.test +++ b/test-data/unit/pythoneval.test @@ -852,13 +852,13 @@ o6 = t.Deque[int]() reveal_type(o6) [out] -_testCollectionsAliases.py:5: note: Revealed type is "collections.Counter[builtins.int]" +_testCollectionsAliases.py:5: note: Revealed type is "collections.Counter[int]" _testCollectionsAliases.py:6: error: Invalid index type "str" for "Counter[int]"; expected type "int" -_testCollectionsAliases.py:9: note: Revealed type is "collections.ChainMap[builtins.int, builtins.str]" -_testCollectionsAliases.py:12: note: Revealed type is "collections.deque[builtins.int]" -_testCollectionsAliases.py:15: note: Revealed type is "collections.Counter[builtins.int]" -_testCollectionsAliases.py:18: note: Revealed type is "collections.ChainMap[builtins.int, builtins.str]" -_testCollectionsAliases.py:21: note: Revealed type is "collections.deque[builtins.int]" +_testCollectionsAliases.py:9: note: Revealed type is "collections.ChainMap[int, str]" +_testCollectionsAliases.py:12: note: Revealed type is "collections.deque[int]" +_testCollectionsAliases.py:15: note: Revealed type is "collections.Counter[int]" +_testCollectionsAliases.py:18: note: Revealed type is "collections.ChainMap[int, str]" +_testCollectionsAliases.py:21: note: Revealed type is "collections.deque[int]" [case testChainMapUnimported] ChainMap[int, str]() @@ -1025,10 +1025,10 @@ reveal_type(g) with f('') as s: reveal_type(s) [out] -_program.py:13: note: Revealed type is "def (x: builtins.int) -> contextlib._GeneratorContextManager[builtins.str, None, None]" -_program.py:14: note: Revealed type is "def (*x: builtins.str) -> contextlib._GeneratorContextManager[builtins.int, None, None]" +_program.py:13: note: Revealed type is "def (x: int) -> contextlib._GeneratorContextManager[str, None, None]" +_program.py:14: note: Revealed type is "def (*x: str) -> contextlib._GeneratorContextManager[int, None, None]" _program.py:16: error: Argument 1 to "f" has incompatible type "str"; expected "int" -_program.py:17: note: Revealed type is "builtins.str" +_program.py:17: note: Revealed type is "str" [case testTypedDictGet] # Test that TypedDict get plugin works with typeshed stubs @@ -1053,24 +1053,24 @@ def test_not_total(d: D_not_total) -> None: s = '' reveal_type(d.get(s)) [out] -_testTypedDictGet.py:8: note: Revealed type is "builtins.int" -_testTypedDictGet.py:9: note: Revealed type is "builtins.str" -_testTypedDictGet.py:10: note: Revealed type is "builtins.object" +_testTypedDictGet.py:8: note: Revealed type is "int" +_testTypedDictGet.py:9: note: Revealed type is "str" +_testTypedDictGet.py:10: note: Revealed type is "object" _testTypedDictGet.py:11: error: All overload variants of "get" of "Mapping" require at least one argument _testTypedDictGet.py:11: note: Possible overload variants: _testTypedDictGet.py:11: note: def get(self, str, /) -> object _testTypedDictGet.py:11: note: def get(self, str, object, /) -> object _testTypedDictGet.py:11: note: def [_T] get(self, str, _T, /) -> object -_testTypedDictGet.py:13: note: Revealed type is "builtins.object" -_testTypedDictGet.py:16: note: Revealed type is "builtins.int | None" -_testTypedDictGet.py:17: note: Revealed type is "builtins.str | None" -_testTypedDictGet.py:18: note: Revealed type is "builtins.object" +_testTypedDictGet.py:13: note: Revealed type is "object" +_testTypedDictGet.py:16: note: Revealed type is "int | None" +_testTypedDictGet.py:17: note: Revealed type is "str | None" +_testTypedDictGet.py:18: note: Revealed type is "object" _testTypedDictGet.py:19: error: All overload variants of "get" of "Mapping" require at least one argument _testTypedDictGet.py:19: note: Possible overload variants: _testTypedDictGet.py:19: note: def get(self, str, /) -> object _testTypedDictGet.py:19: note: def get(self, str, object, /) -> object _testTypedDictGet.py:19: note: def [_T] get(self, str, _T, /) -> object -_testTypedDictGet.py:21: note: Revealed type is "builtins.object" +_testTypedDictGet.py:21: note: Revealed type is "object" [case testTypedDictMappingMethods] from typing import TypedDict @@ -1095,18 +1095,18 @@ Cell2 = TypedDict('Cell2', {'value': int}, total=False) c2 = Cell2() reveal_type(c2.pop('value')) [out] -_testTypedDictMappingMethods.py:5: note: Revealed type is "builtins.str" -_testTypedDictMappingMethods.py:6: note: Revealed type is "typing.Iterator[builtins.str]" -_testTypedDictMappingMethods.py:7: note: Revealed type is "builtins.int" -_testTypedDictMappingMethods.py:8: note: Revealed type is "builtins.bool" -_testTypedDictMappingMethods.py:9: note: Revealed type is "_collections_abc.dict_keys[builtins.str, builtins.object]" -_testTypedDictMappingMethods.py:10: note: Revealed type is "_collections_abc.dict_items[builtins.str, builtins.object]" -_testTypedDictMappingMethods.py:11: note: Revealed type is "_collections_abc.dict_values[builtins.str, builtins.object]" -_testTypedDictMappingMethods.py:12: note: Revealed type is "TypedDict('_testTypedDictMappingMethods.Cell', {'value': builtins.int})" -_testTypedDictMappingMethods.py:13: note: Revealed type is "builtins.int" +_testTypedDictMappingMethods.py:5: note: Revealed type is "str" +_testTypedDictMappingMethods.py:6: note: Revealed type is "typing.Iterator[str]" +_testTypedDictMappingMethods.py:7: note: Revealed type is "int" +_testTypedDictMappingMethods.py:8: note: Revealed type is "bool" +_testTypedDictMappingMethods.py:9: note: Revealed type is "_collections_abc.dict_keys[str, object]" +_testTypedDictMappingMethods.py:10: note: Revealed type is "_collections_abc.dict_items[str, object]" +_testTypedDictMappingMethods.py:11: note: Revealed type is "_collections_abc.dict_values[str, object]" +_testTypedDictMappingMethods.py:12: note: Revealed type is "TypedDict(_testTypedDictMappingMethods.Cell, {'value': int})" +_testTypedDictMappingMethods.py:13: note: Revealed type is "int" _testTypedDictMappingMethods.py:15: error: Unexpected TypedDict key "invalid" _testTypedDictMappingMethods.py:16: error: Key "value" of TypedDict "Cell" cannot be deleted -_testTypedDictMappingMethods.py:21: note: Revealed type is "builtins.int" +_testTypedDictMappingMethods.py:21: note: Revealed type is "int" [case testCrashOnComplexCheckWithNamedTupleNext] from typing import NamedTuple, Optional @@ -1149,9 +1149,9 @@ async def main() -> None: reveal_type(a_y) reveal_type(asyncio.gather(*[asyncio.sleep(1), asyncio.sleep(1)])) [out] -_testAsyncioGatherPreciseType.py:9: note: Revealed type is "builtins.str" -_testAsyncioGatherPreciseType.py:10: note: Revealed type is "builtins.str" -_testAsyncioGatherPreciseType.py:11: note: Revealed type is "asyncio.futures.Future[builtins.list[Any]]" +_testAsyncioGatherPreciseType.py:9: note: Revealed type is "str" +_testAsyncioGatherPreciseType.py:10: note: Revealed type is "str" +_testAsyncioGatherPreciseType.py:11: note: Revealed type is "asyncio.futures.Future[list[Any]]" [case testMultipleInheritanceWorksWithTupleTypeGeneric] from typing import SupportsAbs, NamedTuple @@ -1182,12 +1182,12 @@ for a, b in x.items(): reveal_type(a) reveal_type(b) [out] -_testNoCrashOnGenericUnionUnpacking.py:6: note: Revealed type is "builtins.str" -_testNoCrashOnGenericUnionUnpacking.py:7: note: Revealed type is "builtins.str" -_testNoCrashOnGenericUnionUnpacking.py:10: note: Revealed type is "builtins.str | builtins.int" -_testNoCrashOnGenericUnionUnpacking.py:11: note: Revealed type is "builtins.str | builtins.int" -_testNoCrashOnGenericUnionUnpacking.py:15: note: Revealed type is "builtins.int | builtins.str" -_testNoCrashOnGenericUnionUnpacking.py:16: note: Revealed type is "builtins.int | builtins.str" +_testNoCrashOnGenericUnionUnpacking.py:6: note: Revealed type is "str" +_testNoCrashOnGenericUnionUnpacking.py:7: note: Revealed type is "str" +_testNoCrashOnGenericUnionUnpacking.py:10: note: Revealed type is "str | int" +_testNoCrashOnGenericUnionUnpacking.py:11: note: Revealed type is "str | int" +_testNoCrashOnGenericUnionUnpacking.py:15: note: Revealed type is "int | str" +_testNoCrashOnGenericUnionUnpacking.py:16: note: Revealed type is "int | str" [case testMetaclassOpAccess] from typing import Type @@ -1234,7 +1234,7 @@ bar: Type[Union[A, B]] res = bar * 4 reveal_type(res) [out] -_testMetaclassOpAccessUnion.py:16: note: Revealed type is "builtins.str | builtins.int" +_testMetaclassOpAccessUnion.py:16: note: Revealed type is "str | int" [case testMetaclassOpAccessAny] from typing import Type @@ -1280,7 +1280,7 @@ f(N) g(N) reveal_type(list(N)) [out] -_testIntEnumIterable.py:11: note: Revealed type is "builtins.list[_testIntEnumIterable.N]" +_testIntEnumIterable.py:11: note: Revealed type is "list[_testIntEnumIterable.N]" [case testDerivedEnumIterable] from enum import Enum @@ -1344,7 +1344,7 @@ def print_custom_table() -> None: for row in simple_map(format_row, a, a, a, a, a, a, a, a): # 8 columns reveal_type(row) [out] -_testLoadsOfOverloads.py:24: note: Revealed type is "builtins.str" +_testLoadsOfOverloads.py:24: note: Revealed type is "str" [case testReduceWithAnyInstance] from typing import Iterable @@ -1376,7 +1376,7 @@ X = namedtuple('X', ['a', 'b']) x = X(a=1, b='s') [out] -_testNamedTupleNew.py:12: note: Revealed type is "tuple[builtins.int, fallback=_testNamedTupleNew.Child]" +_testNamedTupleNew.py:12: note: Revealed type is "tuple[int, fallback=_testNamedTupleNew.Child]" [case testNamedTupleTypeInheritanceSpecialCase] from typing import NamedTuple, Tuple @@ -1398,9 +1398,9 @@ accepts_named_tuple(b) accepts_named_tuple(1) accepts_named_tuple((1, 2)) [out] -_testNamedTupleTypeInheritanceSpecialCase.py:8: note: Revealed type is "builtins.dict[builtins.str, Any]" -_testNamedTupleTypeInheritanceSpecialCase.py:9: note: Revealed type is "builtins.tuple[builtins.str, ...]" -_testNamedTupleTypeInheritanceSpecialCase.py:10: note: Revealed type is "builtins.dict[builtins.str, Any]" +_testNamedTupleTypeInheritanceSpecialCase.py:8: note: Revealed type is "dict[str, Any]" +_testNamedTupleTypeInheritanceSpecialCase.py:9: note: Revealed type is "tuple[str, ...]" +_testNamedTupleTypeInheritanceSpecialCase.py:10: note: Revealed type is "dict[str, Any]" _testNamedTupleTypeInheritanceSpecialCase.py:17: error: Argument 1 to "accepts_named_tuple" has incompatible type "int"; expected "NamedTuple" _testNamedTupleTypeInheritanceSpecialCase.py:18: error: Argument 1 to "accepts_named_tuple" has incompatible type "tuple[int, int]"; expected "NamedTuple" @@ -1410,7 +1410,7 @@ from typing import Dict, List, Tuple x: Dict[str, List[int]] reveal_type(x['test'][0]) [out] -_testNewAnalyzerBasicTypeshed_newsemanal.py:4: note: Revealed type is "builtins.int" +_testNewAnalyzerBasicTypeshed_newsemanal.py:4: note: Revealed type is "int" [case testNewAnalyzerTypedDictInStub_newsemanal] import stub @@ -1426,7 +1426,7 @@ class StuffDict(TypedDict): def thing(stuff: StuffDict) -> int: ... [out] -_testNewAnalyzerTypedDictInStub_newsemanal.py:2: note: Revealed type is "def (stuff: TypedDict('stub.StuffDict', {'foo': builtins.str, 'bar': builtins.int})) -> builtins.int" +_testNewAnalyzerTypedDictInStub_newsemanal.py:2: note: Revealed type is "def (stuff: TypedDict(stub.StuffDict, {'foo': str, 'bar': int})) -> int" [case testStrictEqualityAllowlist] # mypy: strict-equality @@ -1551,14 +1551,14 @@ from typing import OrderedDict x: OrderedDict[str, int] = OrderedDict({}) reveal_type(x) [out] -_testTypingOrderedDictAlias.py:3: note: Revealed type is "collections.OrderedDict[builtins.str, builtins.int]" +_testTypingOrderedDictAlias.py:3: note: Revealed type is "collections.OrderedDict[str, int]" [case testTypingExtensionsOrderedDictAlias] from typing_extensions import OrderedDict x: OrderedDict[str, str] = OrderedDict({}) -reveal_type(x) # Revealed type is "collections.OrderedDict[builtins.str, builtins.int]" +reveal_type(x) [out] -_testTypingExtensionsOrderedDictAlias.py:3: note: Revealed type is "collections.OrderedDict[builtins.str, builtins.str]" +_testTypingExtensionsOrderedDictAlias.py:3: note: Revealed type is "collections.OrderedDict[str, str]" [case testSpecialTypingProtocols] # flags: --warn-unreachable @@ -1570,7 +1570,7 @@ if isinstance(obj, Hashable): if isinstance(obj, Awaitable): reveal_type(obj) [out] -_testSpecialTypingProtocols.py:6: note: Revealed type is "tuple[builtins.int]" +_testSpecialTypingProtocols.py:6: note: Revealed type is "tuple[int]" _testSpecialTypingProtocols.py:8: error: Statement is unreachable [case testTypeshedRecursiveTypesExample] @@ -1608,10 +1608,10 @@ else: reveal_type(k) [out] -_testNarrowTypeForDictKeys.py:6: note: Revealed type is "builtins.str" -_testNarrowTypeForDictKeys.py:8: note: Revealed type is "builtins.str | None" -_testNarrowTypeForDictKeys.py:13: note: Revealed type is "builtins.str" -_testNarrowTypeForDictKeys.py:15: note: Revealed type is "builtins.str | None" +_testNarrowTypeForDictKeys.py:6: note: Revealed type is "str" +_testNarrowTypeForDictKeys.py:8: note: Revealed type is "str | None" +_testNarrowTypeForDictKeys.py:13: note: Revealed type is "str" +_testNarrowTypeForDictKeys.py:15: note: Revealed type is "str | None" [case testTypeAliasWithNewStyleUnion] # flags: --python-version 3.10 @@ -1651,8 +1651,8 @@ def foo(x: T) -> T: return x [out] _testTypeAliasWithNewStyleUnion.py:5: note: Revealed type is "typing._SpecialForm" -_testTypeAliasWithNewStyleUnion.py:25: note: Revealed type is "type[builtins.int] | builtins.str" -_testTypeAliasWithNewStyleUnion.py:28: note: Revealed type is "type[builtins.int] | builtins.str" +_testTypeAliasWithNewStyleUnion.py:25: note: Revealed type is "type[int] | str" +_testTypeAliasWithNewStyleUnion.py:28: note: Revealed type is "type[int] | str" [case testTypeAliasWithNewStyleUnionInStub] import m @@ -1704,13 +1704,13 @@ CU3 = int | Callable[[str | bool], str] CU4: TypeAlias = int | Callable[[str | bool], str] [out] m.pyi:5: note: Revealed type is "typing._SpecialForm" -m.pyi:22: note: Revealed type is "types.UnionType[type[builtins.int], builtins.str]" -_testTypeAliasWithNewStyleUnionInStub.py:3: note: Revealed type is "type[builtins.int] | builtins.str" -_testTypeAliasWithNewStyleUnionInStub.py:5: note: Revealed type is "type[builtins.int] | builtins.str" -_testTypeAliasWithNewStyleUnionInStub.py:7: note: Revealed type is "type[builtins.int] | builtins.str" -_testTypeAliasWithNewStyleUnionInStub.py:9: note: Revealed type is "type[builtins.int] | builtins.str" -_testTypeAliasWithNewStyleUnionInStub.py:11: note: Revealed type is "builtins.str | type[builtins.int]" -_testTypeAliasWithNewStyleUnionInStub.py:13: note: Revealed type is "builtins.str | type[builtins.int]" +m.pyi:22: note: Revealed type is "types.UnionType[type[int], str]" +_testTypeAliasWithNewStyleUnionInStub.py:3: note: Revealed type is "type[int] | str" +_testTypeAliasWithNewStyleUnionInStub.py:5: note: Revealed type is "type[int] | str" +_testTypeAliasWithNewStyleUnionInStub.py:7: note: Revealed type is "type[int] | str" +_testTypeAliasWithNewStyleUnionInStub.py:9: note: Revealed type is "type[int] | str" +_testTypeAliasWithNewStyleUnionInStub.py:11: note: Revealed type is "str | type[int]" +_testTypeAliasWithNewStyleUnionInStub.py:13: note: Revealed type is "str | type[int]" [case testEnumNameWorkCorrectlyOn311] # flags: --python-version 3.11 @@ -1729,11 +1729,11 @@ reveal_type(E.X.name) reveal_type(e.foo) reveal_type(E.Y.foo) [out] -_testEnumNameWorkCorrectlyOn311.py:11: note: Revealed type is "builtins.str" +_testEnumNameWorkCorrectlyOn311.py:11: note: Revealed type is "str" _testEnumNameWorkCorrectlyOn311.py:12: note: Revealed type is "Literal[1]? | Literal[2]?" _testEnumNameWorkCorrectlyOn311.py:13: note: Revealed type is "Literal['X']?" -_testEnumNameWorkCorrectlyOn311.py:14: note: Revealed type is "builtins.int" -_testEnumNameWorkCorrectlyOn311.py:15: note: Revealed type is "builtins.int" +_testEnumNameWorkCorrectlyOn311.py:14: note: Revealed type is "int" +_testEnumNameWorkCorrectlyOn311.py:15: note: Revealed type is "int" [case testTypeAliasNotSupportedWithNewStyleUnion] # flags: --python-version 3.9 @@ -1766,7 +1766,7 @@ def foo(k: str) -> TD: reveal_type(x.get(k, {})) return x.get(k, {}) [out] -_testTypedDictUnionGetFull.py:11: note: Revealed type is "TypedDict('_testTypedDictUnionGetFull.TD', {'x'?: builtins.int, 'y'?: builtins.int})" +_testTypedDictUnionGetFull.py:11: note: Revealed type is "TypedDict(_testTypedDictUnionGetFull.TD, {'x'?: int, 'y'?: int})" [case testTupleWithDifferentArgsPy310] # https://github.com/python/mypy/issues/11098 @@ -1799,15 +1799,15 @@ WrongEllipsis = tuple[float, float, ...] | str # Error reveal_type(tuple[int, str]((1, "x"))) [out] -_testTupleWithDifferentArgsPy310.py:15: note: Revealed type is "builtins.str | tuple[builtins.float, builtins.float, builtins.str]" -_testTupleWithDifferentArgsPy310.py:16: note: Revealed type is "tuple[builtins.float] | builtins.str" -_testTupleWithDifferentArgsPy310.py:17: note: Revealed type is "builtins.tuple[builtins.float, ...] | builtins.str" -_testTupleWithDifferentArgsPy310.py:18: note: Revealed type is "tuple[builtins.float, builtins.str]" -_testTupleWithDifferentArgsPy310.py:19: note: Revealed type is "builtins.tuple[builtins.float, ...]" -_testTupleWithDifferentArgsPy310.py:20: note: Revealed type is "builtins.list[tuple[builtins.int, builtins.str]]" +_testTupleWithDifferentArgsPy310.py:15: note: Revealed type is "str | tuple[float, float, str]" +_testTupleWithDifferentArgsPy310.py:16: note: Revealed type is "tuple[float] | str" +_testTupleWithDifferentArgsPy310.py:17: note: Revealed type is "tuple[float, ...] | str" +_testTupleWithDifferentArgsPy310.py:18: note: Revealed type is "tuple[float, str]" +_testTupleWithDifferentArgsPy310.py:19: note: Revealed type is "tuple[float, ...]" +_testTupleWithDifferentArgsPy310.py:20: note: Revealed type is "list[tuple[int, str]]" _testTupleWithDifferentArgsPy310.py:26: error: Invalid type: try using Literal[1] instead? _testTupleWithDifferentArgsPy310.py:27: error: Unexpected "..." -_testTupleWithDifferentArgsPy310.py:29: note: Revealed type is "tuple[builtins.int, builtins.str]" +_testTupleWithDifferentArgsPy310.py:29: note: Revealed type is "tuple[int, str]" [case testEnumIterMetaInference] import socket @@ -1824,8 +1824,8 @@ def enum_iter(cls: Type[_E]) -> Iterable[_E]: for value in enum_iter(socket.SocketKind): reveal_type(value) [out] -_testEnumIterMetaInference.py:8: note: Revealed type is "typing.Iterator[_E`-1]" -_testEnumIterMetaInference.py:9: note: Revealed type is "_E`-1" +_testEnumIterMetaInference.py:8: note: Revealed type is "typing.Iterator[_E]" +_testEnumIterMetaInference.py:9: note: Revealed type is "_E" _testEnumIterMetaInference.py:13: note: Revealed type is "socket.SocketKind" [case testEnumUnpackedViaMetaclass] @@ -1889,8 +1889,8 @@ def test2() -> None: [out] _testStarUnpackNestedUnderscore.py:10: error: List item 0 has incompatible type "int"; expected "str" _testStarUnpackNestedUnderscore.py:10: error: List item 1 has incompatible type "int"; expected "str" -_testStarUnpackNestedUnderscore.py:11: note: Revealed type is "builtins.list[builtins.str]" -_testStarUnpackNestedUnderscore.py:16: note: Revealed type is "builtins.list[builtins.object]" +_testStarUnpackNestedUnderscore.py:11: note: Revealed type is "list[str]" +_testStarUnpackNestedUnderscore.py:16: note: Revealed type is "list[object]" [case testStrictEqualitywithParamSpec] # flags: --strict-equality @@ -1946,8 +1946,8 @@ Foo.__dict__ = {} Foo().__dict__ = {} [out] -_testInferenceOfDunderDictOnClassObjects.py:2: note: Revealed type is "types.MappingProxyType[builtins.str, Any]" -_testInferenceOfDunderDictOnClassObjects.py:3: note: Revealed type is "builtins.dict[builtins.str, Any]" +_testInferenceOfDunderDictOnClassObjects.py:2: note: Revealed type is "types.MappingProxyType[str, Any]" +_testInferenceOfDunderDictOnClassObjects.py:3: note: Revealed type is "dict[str, Any]" _testInferenceOfDunderDictOnClassObjects.py:4: error: Cannot assign to final attribute "__dict__" _testInferenceOfDunderDictOnClassObjects.py:4: error: Incompatible types in assignment (expression has type "dict[Never, Never]", variable has type "MappingProxyType[str, Any]") @@ -2058,7 +2058,7 @@ class Description: def f(d: Description) -> None: reveal_type(d.name_fn) [out] -_testDataclassStrictOptionalAlwaysSet.py:9: note: Revealed type is "def (builtins.int | None) -> builtins.str | None" +_testDataclassStrictOptionalAlwaysSet.py:9: note: Revealed type is "def (int | None) -> str | None" [case testPEP695VarianceInference] # flags: --python-version=3.12 @@ -2204,8 +2204,8 @@ x = [1, 2] reveal_type([*reversed(x)]) reveal_type([*map(str, x)]) [out] -_testUnpackIteratorBuiltins.py:4: note: Revealed type is "builtins.list[builtins.int]" -_testUnpackIteratorBuiltins.py:5: note: Revealed type is "builtins.list[builtins.str]" +_testUnpackIteratorBuiltins.py:4: note: Revealed type is "list[int]" +_testUnpackIteratorBuiltins.py:5: note: Revealed type is "list[str]" [case testReturnFallbackInferenceDict] # Requires full dict stubs. diff --git a/test-data/unit/semanal-symtable.test b/test-data/unit/semanal-symtable.test index 1622fd1f1ad4..79500c661138 100644 --- a/test-data/unit/semanal-symtable.test +++ b/test-data/unit/semanal-symtable.test @@ -9,7 +9,7 @@ x = 1 [out] __main__: SymbolTable( - x : Gdef/Var (__main__.x) : builtins.int) + x : Gdef/Var (__main__.x) : int) [case testFuncDef] def f(): pass @@ -35,7 +35,7 @@ __main__: m : Gdef/MypyFile (m)) m: SymbolTable( - x : Gdef/Var (m.x) : builtins.int) + x : Gdef/Var (m.x) : int) [case testImportFromModule] from m import x @@ -49,7 +49,7 @@ __main__: m: SymbolTable( x : Gdef/TypeInfo (m.x) - y : Gdef/Var (m.y) : builtins.int) + y : Gdef/Var (m.y) : int) [case testImportAs] from m import x as xx @@ -63,7 +63,7 @@ __main__: m: SymbolTable( x : Gdef/TypeInfo (m.x) - y : Gdef/Var (m.y) : builtins.int) + y : Gdef/Var (m.y) : int) [case testFailingImports] from sys import non_existing1 # type: ignore @@ -91,6 +91,6 @@ def g() -> None: [out] __main__: SymbolTable( - Callable : Gdef/Var (typing.Callable) : builtins.int + Callable : Gdef/Var (typing.Callable) : int dec : Gdef/FuncDef (__main__.dec) : def (f: def ()) -> def () g : Gdef/Decorator (__main__.g) : def ())