mypy icon indicating copy to clipboard operation
mypy copied to clipboard

fix: Mismatched signature between checker plugin API and implementation

Open bzoracler opened this issue 1 year ago • 2 comments

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.

bzoracler avatar Jun 07 '24 20:06 bzoracler

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

github-actions[bot] avatar Jun 07 '24 20:06 github-actions[bot]

Fixes #17442

bzoracler avatar Jun 27 '24 09:06 bzoracler

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

github-actions[bot] avatar Jul 01 '24 21:07 github-actions[bot]