Skip to content

Remove _ProxyFile.__class_getitem__ #140808

Description

@srittau

Feature or enhancement

Proposal:

#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?

Cc @emmatyping @JelleZijlstra @AlexWaygood

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. emmatyping commented on Oct 31, 2025

    @emmatyping
    Member

    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.

  2. added a commit that references this issue on Nov 2, 2025
  3. added a commit that references this issue on Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-emailtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions