Closed as not planned
Description
Summary
Not sure how else to title this issue, since this is two issues in one which relate to the same usecase.
class A:
foo: int
class B:
pass
def bar(p: A | B):
p.foo = 4
print(p.foo)
This produces two issues:
Object of type `Literal[4]` is not assignable to attribute `foo` on type `A | B` (invalid-assignment) [Ln 8, Col 5]
Attribute `foo` on type `A | B` is possibly unbound (possibly-unbound-attribute) [Ln 9, Col 11]
First of all, there should be a way to allow assignments like that via config.
But also, in this case, p.foo is guaranteed to be defined, so the possibly-unbound-attribute
rule is a false positive.
Version
No response