Open
Description
Currently there is some duplication around partial types:
- Logic in
try_infer_partial_generic_type_from_assignment()
essentially duplicates the logic inlined incheck_assignment()
forNone
partial types. These two probably can be refactored to the same method if we also updatehandle_partial_var_type()
to not special-case partialNone
types, and instead consistently return a partial type in lvalue context. - Logic in
try_infer_partial_type_from_indexed_assignment()
duplicates that intry_infer_partial_type()
(there is already a TODO item). This one can be refactored by either pushing the latter a bit down the call stack (closer tocheck_call()
), or by generating a syntheticCallExpr
with__setitem__
and passing it totry_infer_partial_type()
.
The second item may be something to watch out when implementing support for these:
a = defaultdict(list)
a[0].append('yes')
b = {}
b.setdefault(0, []).append('yes')
c = defaultdict(set)
c[0].add('yes')
d = {}
d.setdefault(0, set()).add('yes')
@JukkaL this is probably not something important, but maybe it makes sense to fix this while we are at it?