KEMBAR78
fix: Mismatched signature between checker plugin API and implementation by bzoracler · Pull Request #17343 · python/mypy · GitHub
Skip to content

Conversation

bzoracler
Copy link
Contributor

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.

@github-actions

This comment has been minimized.

@bzoracler
Copy link
Contributor Author

Fixes #17442

@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2024

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

@hauntsaninja hauntsaninja merged commit db9837f into python:master Jul 24, 2024
@bzoracler bzoracler deleted the fix-checker-api-fail-signature branch July 24, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants