You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#19425 made the internal file wrapper mailbox._ProxyFile generic, probably because it was generic over AnyStr in typeshed. (Unchanged since mailbox.pyi was added in python/typeshed#3427. There was no discussion about it back then.)
_ProxyFile does not need to be generic, as it's only used internally by mailbox.py and is always initialized with a binary file object (as returned by open()). In fact, this now complicates the stubs for mailbox.pyi, because we need to carry the generic-ness of this class through to other protocols. See python/typeshed#14950 for details.
I suggest to remove __class_getitem__ again, although this probably needs to go through the deprecation process, even though this is an internal class?
I think this makes sense to remove. As you say, these are private APIs, so per PEP 387:
Others are explicitly not part of the public API. They can change or be removed at any time in any way. These include:
Function, class, module, attribute, method, and C-API names and types that are prefixed by “_” (except special names).
Looking on GitHub, I saw 2 references to the classes at all, neither in typed contexts, so I think it should be safe to remove __class_getitem__, especially since these are internal details users shouldn't be interacting with.
Activity
emmatyping commentedon Oct 31, 2025
I think this makes sense to remove. As you say, these are private APIs, so per PEP 387:
Looking on GitHub, I saw 2 references to the classes at all, neither in typed contexts, so I think it should be safe to remove
__class_getitem__, especially since these are internal details users shouldn't be interacting with.gh-140808: Remove __class_getitem__ from mailbox._ProxyFile (#140838)
pythongh-140808: Remove __class_getitem__ from mailbox._ProxyFile (py…