Skip to content

Commit 6c55624

Browse files
committed
Use fallback (bound) of ParamSpec.kwargs
1 parent 662bbeb commit 6c55624

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mypyc/irbuild/builder.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
AnyType,
4848
DeletedType,
4949
Instance,
50+
ParamSpecType,
5051
ProperType,
5152
TupleType,
5253
Type,
@@ -970,6 +971,12 @@ def get_dict_base_type(self, expr: Expression) -> list[Instance]:
970971
t = t.fallback
971972
dict_base = next(base for base in t.type.mro if base.fullname == "typing.Mapping")
972973
else:
974+
if isinstance(t, ParamSpecType):
975+
# Since `ParamSpec(upper_bound=...)` is not defined yet, we know that
976+
# `bound` is set to `dict[str, object]`. In any future sane implementation
977+
# it still has to be exactly a `dict` as that's how kwargs work
978+
# at runtime.
979+
t = get_proper_type(t.upper_bound)
973980
assert isinstance(t, Instance), t
974981
dict_base = next(base for base in t.type.mro if base.fullname == "builtins.dict")
975982
dict_types.append(map_instance_to_supertype(t, dict_base))

0 commit comments

Comments
 (0)