mypy
mypy copied to clipboard
fix: Mismatched signature between checker plugin API and implementation
This PR changes the fail method's signature to be positional-only for the first two parameters, due to a mismatch between the CheckerPluginInterface signature and the implementation class (TypeChecker).
class CheckerPluginInterface:
...
@abstractmethod
def fail(
self, msg: str | ErrorMessage, ctx: Context, *, code: ErrorCode | None = None
) -> None: ...
class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
...
def fail(
self, msg: str | ErrorMessage, context: Context, *, code: ErrorCode | None = None
) -> None:
An alternative fix would be to change TypeChecker.fail's parameter name to ctx, but that has a greater disruption potential.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅
Fixes #17442
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅