Basedpyright is giving me errors when I initialize an empty collection without annotations for the item generic and then try to append to it.
Minimum reproducible example:
a = []
a.append(1) # ERROR: Type of "append" is partially unknown [reportUnknownMemberType]
Other typecheckers seem to be ok with this kind of pattern. mypy --strict doesn't find any problems with the example above. It correctly infers it as list[int] when I run reveal_type(). However if I try to append a string to a after appending 1, it correctly complains that they don't match:
# mypy:
from typing_extensions import reveal_type
a = []
a.append(1) # fine for mypy
reveal_type(a) # mypy gives list[int], while basedpyright gives list[Unknown]
a.append("oops") # mypy complains that this doesn't match list[int]
Initializing an empty collection is a common pattern, so it would make sense to support it (infer) without giving an error.
Basedpyright is giving me errors when I initialize an empty collection without annotations for the item generic and then try to append to it.
Minimum reproducible example:
Other typecheckers seem to be ok with this kind of pattern.
mypy --strict
doesn't find any problems with the example above. It correctly infers it as list[int] when I run reveal_type(). However if I try to append a string to a after appending 1, it correctly complains that they don't match:Initializing an empty collection is a common pattern, so it would make sense to support it (infer) without giving an error.