I think it’s important to make it clear what problems we’re dealing with:
There are 2 different problems being discussed here, and these 2 problems are only slightly related to each other.
Problem A
The type of the argument for __contains__ (whether it is object or _T_co) is currently inconsistent and technically unsafe.
This is why str is technically not a valid Sequence.
Although it is technically unsafe, and working to make the Python type system more safe is worthwhile, we should note that not very many users run into issues with this problem.
Problem B
Users often want to design an API like this:
def foo(x: Iterable[str]):
...
(Iterable[str] could be replaced with Sequence[str] or Collection[str] or others, but Iterable and Sequence are the most common.)
It is usually a bug if someone passes a str to this function.
foo("abc")
Users expect the type-checker to report an error for this, because this isn’t a type they’re expecting, but it doesn’t report an error.
And (in the case of Iterable) there isn’t any good way to annotate this so the type checker will report an error for this bug.
This is a common issue that many users run into, and they report issues with mypy and pyright and other typing projects.
One of the most significant ways to describe how these 2 problems are related to each other is that:
The existence of one problem makes it possible to have a hacky-workaround-half-solution to the other problem.