| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The covariant protocol from python#14786 loses a bound TypeVar whose __replace__ returns Self (dataclasses, namedtuples). Add a Self overload that keeps the argument's type, falling back to the covariant one so Box[int] -> Box[str] still works.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #15973
copy.replace drops a bound TypeVar when __replace__ returns Self, so replace(config: T, ...) comes back as the bound instead of T.
#14786 made the protocol covariant for the Box[int] -> Box[str] case, which broke this one. Rather than pick between them, I added a Self-returning overload first that keeps T; anything like Box falls through to the covariant overload. Both work now, and the new test cases fail without it.
(#14819 touches the same stub, so one of us will need a rebase.)