Allow covariance for read-only attributes#8350
Allow covariance for read-only attributes#8350msullivan merged 7 commits intopython:masterfrom TH3CHARLie:fix-5836
Conversation
What's missing in text fixtures? Maybe you can simplify the examples to not rely on so many features. |
Good point. I've simplified the case from #5836 and added it. I've also done some refactor work to reuse the new helper added and modify the function's name to make it less misleading. But it is not the main focus of the PR and I'd like to know your thoughts on it. @JukkaL |
msullivan
left a comment
There was a problem hiding this comment.
OK this seems like a reasonable improvement. I think this doesn't affect all attributes. Regular attributes we just always allow covariant overriding of, even when it is totally wrong.
resolves #5836
For now, I've not added any tests yet. I've tested against code samples in #5836 and #3260 and the patch is working but adding either of them seems to require modifying a lot in test fixtures
The new helper function
is_writable_attributeis actually borrowed fromcheck_no_writable. I'd also like to refactor the latter function's name and implement it using the new helper in this PR, since I think its name is kind of misleading considering the commentsmypy/mypy/checker.py
Lines 2391 to 2402 in ea3c65c