Repository navigation
gh-102936: typing: document performance pitfalls of protocols decorated with @runtime_checkable - #102937
Conversation
…untime_checkable`
|
|
||
| assert isinstance(open('/some/file'), Closable) | ||
|
|
||
| @runtime_checkable |
There was a problem hiding this comment.
I think many users aren't too familiar with OSError's constructor / we can't use kwargs and it's unclear what the second argument is. Maybe we could use int and HasNumerator instead?
(I know it's not writeable, but OSError's errno also is maybe not writeable? Writing to errno doesn't affect repr)
There was a problem hiding this comment.
Yeah, I was really struggling to think of a good example for this! I'll ponder some more and see if I can come up with something better...
There was a problem hiding this comment.
Perhaps unsurprisingly, not too many good cases of writeable attributes in stdlib. Maybe Thread.name? It's explicitly documented as something you can write to.
There was a problem hiding this comment.
That works! I'll make the change tomorrow (it's late here)
commented
Mar 23, 2023
|
Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
commented
Mar 23, 2023
|
GH-102963 is a backport of this pull request to the 3.11 branch. |
commented
Mar 23, 2023
|
GH-102964 is a backport of this pull request to the 3.10 branch. |
commented
Mar 23, 2023
|
Thanks all for the reviews! |
@runtime_checkable#102936