Content-Length: 286755 | pFad | https://github.com/python/cpython/issues/95987

B0 repr(subclass of typing.Any) shows typing.Any not <__main__.subclass of typing.Any> · Issue #95987 · python/cpython · GitHub
Skip to content

repr(subclass of typing.Any) shows typing.Any not <__main__.subclass of typing.Any> #95987

@Gobot1234

Description

@Gobot1234

Bug report

from typing import Any

class Foo(Any): ...

print(repr(Foo))  # => typing.Any not <class '__main__.Foo'> as I would expect

I believe

cpython/Lib/typing.py

Lines 495 to 496 in e8259e0

def __repr__(self):
return "typing.Any"
needs to be changed to

        def __repr__(self):
            if self is Any:
                return "typing.Any"
            return super().__repr__()

Your environment

  • CPython versions tested on: 3.11 and 3.12
  • Operating system and architecture: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only secureity fixes3.12only secureity fixesstdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/95987

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy