Skip to content

Commit f6e5a5c

Browse files
Fix missing dependency trigger for sentinel literals
1 parent 48c1234 commit f6e5a5c

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

mypy/server/deps.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class 'mod.Cls'. This can also refer to an attribute inherited from a
158158
ParamSpecType,
159159
PartialType,
160160
ProperType,
161+
SentinelValue,
161162
TupleType,
162163
Type,
163164
TypeAliasType,
@@ -1096,7 +1097,10 @@ def visit_typeddict_type(self, typ: TypedDictType) -> list[str]:
10961097
return triggers
10971098

10981099
def visit_literal_type(self, typ: LiteralType) -> list[str]:
1099-
return self.get_type_triggers(typ.fallback)
1100+
triggers = self.get_type_triggers(typ.fallback)
1101+
if isinstance(typ.value, SentinelValue):
1102+
triggers.append(make_trigger(typ.value.fullname))
1103+
return triggers
11001104

11011105
def visit_unbound_type(self, typ: UnboundType) -> list[str]:
11021106
return []

test-data/unit/deps-types.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,3 +1026,14 @@ class P(Protocol):
10261026
<mod.P> -> <m.x>, m, mod.P
10271027
<mod.P[wildcard]> -> <mod.P>
10281028
<mod> -> m
1029+
1030+
[case testSentinelType]
1031+
from typing_extensions import Sentinel
1032+
1033+
MISSING = Sentinel("MISSING")
1034+
1035+
def f(x: MISSING) -> None:
1036+
pass
1037+
[builtins fixtures/tuple.pyi]
1038+
[out]
1039+
<m.MISSING> -> <m.MISSING>, <m.f>, m, m.f

0 commit comments

Comments
 (0)