configparser.ConfigParser.values()
should return a ValuesView[configparser.SectionProxy]
#11547
Labels
stubs: false positive
Type checkers report false errors
Consider these two similar python programs, which have identical behavior:
and
(The only difference between the two programs is invoking
cparser.items()
orcparser.values()
)The first program type-checks in
mypy
without any issues, but the second program:The problem is that
ConfigParser
objects accept assignment of arbitrarystr
->str
mappings but when you pull a value back out of aConfigParser
, the value pulled out is always aconfigparser.SectionProxy
. (see the__getitem__
and__setitem__
methods onconfigparser.RawConfigParser
)Note that this affects not only the return type of
values
but also the return type of__getitem__
; it should be perfectly well-typed to writecparser[some_str_value].name
.The text was updated successfully, but these errors were encountered: