Suggestion: more precise inference when all elements are of same generic type #8392
Labels
feature
priority-2-low
topic-join-v-union
Using join vs. using unions
topic-type-variables
topic-usability
Consider the following cases:
Inferring the most precise type which is a parent of all the element types makes sense, but IMO the element type of
nested
should be inferred to beList[object]
instead ofobject
.I'm using
List
here as a placeholder for any generic type - this is really more of an issue for things like Hypothesis strategies such asfixed_dictionaries()
, with signature(Mapping[K, SearchStrategy[V]],) -> SearchStrategy[Mapping[K, V]]
.This was reported downstream in HypothesisWorks/hypothesis#2349, because
fixed_dictionaries({"num": integers(), "string": text()})
works but fails to type-check unless all values are strategies for the same type or the mapping is assigned to a type-annotated variable first.Python 3.8 and Mypy 0.761, but it's not dependent on Python version.
The text was updated successfully, but these errors were encountered: