Skip to content

Subclass of typing.Any cannot be instantiated with arguments #117110

Closed
@Azureblade3808

Description

@Azureblade3808

Bug report

Bug description:

from typing import Any

class C(Any):
    def __init__(self, v): ...

C(0)   # TypeError: object.__new__() takes exactly one argument (the type to instantiate)

The fix should be easy. Just replace --

        return super().__new__(cls, *args, **kwargs)

with --

        return super().__new__(cls)

in typing.Any.__new__(...), as the superclass is object and its __new__ doesn't accept additional arguments.

CPython versions tested on:

3.12

Operating systems tested on:

Linux, Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions