Skip to content

Allow error on incorrect implicit argument to zero-argument super()#2253

Open
carljm wants to merge 1 commit intopython:mainfrom
carljm:cjm/meta-super
Open

Allow error on incorrect implicit argument to zero-argument super()#2253
carljm wants to merge 1 commit intopython:mainfrom
carljm:cjm/meta-super

Conversation

@carljm
Copy link
Copy Markdown
Member

@carljm carljm commented Apr 8, 2026

The full rationale for this PR is explained at https://discuss.python.org/t/cls-type-t-and-super/106893

@carljm carljm added the topic: conformance tests Issues with the conformance test suite label Apr 8, 2026
class Meta3(type):
def __call__(cls: type[T], *args, **kwargs) -> T:
return super().__call__(*args, **kwargs)
return super().__call__(*args, **kwargs) # E?: type[T] is not an instance or subclass of `Meta3`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't really making any assertions about support for super() at all -- it's making assertions about how type checkers should interpret constructor calls. So we could sidestep the issue of zero-argument-super() entirely here:

Suggested change
return super().__call__(*args, **kwargs) # E?: type[T] is not an instance or subclass of `Meta3`
return type.__call__(cls, *args, **kwargs)

All type checkers appear to be happy if you make that change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: conformance tests Issues with the conformance test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants