Improve error messages for `super` checks and add more tests by sobolevn · Pull Request #16393 · python/mypy

@sobolevn

Now all messages use the same "super" formatting, it used to be a bit different.

@sobolevn

@sobolevn

@github-actions

This comment has been minimized.

JelleZijlstra

@sobolevn

hauntsaninja

AlexWaygood

@staticmethod
def st() -> int:
reveal_type(super(B, B).st()) # N: Revealed type is "builtins.int"
super().st() # E: "super" requires one or more positional arguments in enclosing function

Choose a reason for hiding this comment

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

Here again, it's specifically the zero-argument form of super() that we're complaining about (the reveal_type() call in the line immediately above this one works fine for the two-argument form of super()). So I'd keep the () here as well, personally

Choose a reason for hiding this comment

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

And it should be "one or two" not "one or more" 👍

@github-actions

This comment has been minimized.

@sobolevn

@github-actions

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅