KotlinIsland / KotlinIsland/basedmypy
unsafe variance errors shouldn't propagate down
- Dominant language
- Python
- Stars
- 202
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
Same thing with unsafe variance in protocol inheritance:
```py
from typing import Protocol, _T_co as T_co
class A(Protocol[T_co]): # type: ignore
def foo(self, t: T_co) -> None: ... # type: ignore
class B(A[T_co], Protocol): # ERROR! using covariant type variable where invariant one expected!!!
def bar(self) -> T_co: ...
```
[playground](https://mypy-play.net/?gist=f763a37b161f534caa8a76e67ff24757)
Contributor guide
Research direction
Start with the minimal Python reproduction in the issue and compare its diagnostics with the linked mypy-play playground. Trace protocol inheritance and unsafe-variance checking to determine why the error propagates into B; done means the shown inheritance pattern no longer reports the unwanted error while preserving the relevant variance checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100