Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ def test_any_works_with_alias(self):
typing.Pattern[Any]
typing.IO[Any]

def test_subclass_can_instantiate_with_arguments(self):
class Sub(Any):
def __init__(self, *args, **kwargs): pass
# The instantiation must not fail.
Sub(0, s="")


class BottomTypeTestsMixin:
bottom_type: ClassVar[Any]
Expand Down
2 changes: 1 addition & 1 deletion Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class Any(metaclass=_AnyMeta):
def __new__(cls, *args, **kwargs):
if cls is Any:
raise TypeError("Any cannot be instantiated")
return super().__new__(cls, *args, **kwargs)
return super().__new__(cls)


@_SpecialForm
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that prevents subclasses of :class:`typing.Any` to be instantiated with arguments. Patch by Chris Fu.