PY-24834 Report specific strict union members missing an attribute

It also fixed problems with not reporting an error when a union
contained an incompatible class but didn't contain Any
(there was an unnecessary isWeak check) as well
as reporting false positives when a union contained special
members types for which we suppress attribute access warnings,
such as classes inheriting from Any or implicit protocols
(PyStructuralType).

Missing equals/hashCode needed to be added to PyStructuralType,
because otherwise PyUnresolvedReferencesInspectionTest.testUnionContainingUnknownType
started blinking due to unions sometimes containing duplicate structural types
(i.e. in some test runs `Union[{smth}, str]` was inferred and in others --
`Union[{smth}, str, {smth}]`).

GitOrigin-RevId: 63f720844c2892d2baa82be19b573221bd4f5d99
This commit is contained in:
Mikhail Golubev
2025-08-12 17:19:34 +00:00
committed by intellij-monorepo-bot
parent d1eaa5fe21
commit 58a45497af
9 changed files with 92 additions and 49 deletions
@@ -936,7 +936,7 @@ INSP.unresolved.refs.class.object.has.no.attribute=''{0}'' object has no attribu
INSP.unresolved.refs.import.resolves.to.its.containing.file=Import resolves to its containing file
INSP.unresolved.refs.class.does.not.define.operator=Class ''{0}'' does not define ''{1}'', so the ''{2}'' operator cannot be used on its instances
INSP.unresolved.refs.ignore.references.label=Ignored references:
INSP.unresolved.refs.unresolved.attribute.in.union.type=Some members of ''{0}'' don''t have attribute ''{1}''
INSP.unresolved.refs.unresolved.attribute.in.union.type=Member ''{0}'' of ''{1}'' does not have attribute ''{2}''
unresolved.docstring.param.reference=Function ''{0}'' does not have a parameter ''{1}''
unresolved.import.reference=No module named ''{0}''