Skip to content

Commit

Permalink
fix python#16935 use builtins.type not ABCMeta as tuple type obj fall…
Browse files Browse the repository at this point in the history
…back

i.e. the mypy type of the expression union[str, int] is a
CallableType with fallback builtins.type

this matches the mypy type of the expression int
which is a CallableType with fallback builtins.type

(suggested by PR review discussion)
  • Loading branch information
urnest committed Jun 1, 2024
1 parent 5e1b3ff commit 7a39ef5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4846,7 +4846,7 @@ def apply_type_arguments_to_callable(
[ARG_POS],
["p1"],
TupleType(list(args), self.chk.named_type("tuple")),
self.chk.named_type("abc.ABCMeta"),
self.chk.named_type("builtins.type"),
name="tuple",
definition=tp.definition,
bound_args=tp.bound_args,
Expand Down
16 changes: 8 additions & 8 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -3696,8 +3696,8 @@ cache_fine_grained = False
[file mypy.ini.2]
\[mypy]
cache_fine_grained = True
[rechecked _typeshed, a, abc, builtins, typing]
[stale _typeshed, a, abc, builtins, typing]
[rechecked _typeshed, a, builtins, typing]
[stale _typeshed, a, builtins, typing]
[builtins fixtures/tuple.pyi]

[case testIncrementalPackageNameOverload]
Expand Down Expand Up @@ -3748,8 +3748,8 @@ Signature: 8a477f597d28d172789f06886806bc55
[file b.py.2]
# uh
-- Every file should get reloaded, since the cache was invalidated
[stale _typeshed, a, abc, b, builtins, typing]
[rechecked _typeshed, a, abc, b, builtins, typing]
[stale _typeshed, a, b, builtins, typing]
[rechecked _typeshed, a, b, builtins, typing]
[builtins fixtures/tuple.pyi]

[case testIncrementalBustedFineGrainedCache2]
Expand All @@ -3761,8 +3761,8 @@ import b
[file b.py.2]
# uh
-- Every file should get reloaded, since the settings changed
[stale _typeshed, a, abc, b, builtins, typing]
[rechecked _typeshed, a, abc, b, builtins, typing]
[stale _typeshed, a, b, builtins, typing]
[rechecked _typeshed, a, b, builtins, typing]
[builtins fixtures/tuple.pyi]

[case testIncrementalBustedFineGrainedCache3]
Expand All @@ -3777,8 +3777,8 @@ import b
[file b.py.2]
# uh
-- Every file should get reloaded, since the cache was invalidated
[stale _typeshed, a, abc, b, builtins, typing]
[rechecked _typeshed, a, abc, b, builtins, typing]
[stale _typeshed, a, b, builtins, typing]
[rechecked _typeshed, a, b, builtins, typing]
[builtins fixtures/tuple.pyi]

[case testIncrementalWorkingFineGrainedCache]
Expand Down
1 change: 0 additions & 1 deletion test-data/unit/fixtures/tuple.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import _typeshed
from typing import Iterable, Iterator, TypeVar, Generic, Sequence, Optional, overload, Tuple, Type
from abc import ABCMeta

T = TypeVar("T")
Tco = TypeVar('Tco', covariant=True)
Expand Down

0 comments on commit 7a39ef5

Please sign in to comment.