python / python/cpython

Generic class with broken `__eq__` cannot be specialized

Open
#119,972 0 comments 0 reactions 1 assignee View on GitHub

@JelleZijlstra is already working on this.

Since Jun 3, 2024.

3.12 3.13 3.14 topic-typing type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

This test case currently fails:

    def test_buggy_eq(self):
        class BrokenEq(abc.ABCMeta):
            def __eq__(self, other):
                raise TypeError("I'm broken")

        class G(Generic[T], metaclass=BrokenEq):
            pass

        alias = G[int]
        self.assertIs(get_origin(alias), G)
        self.assertEqual(get_args(alias), (int,))

See python/typing_extensions#422 for a real-world example.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-119973

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.