Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Mismatched signature between checker plugin API and implementation #17343

Merged
merged 2 commits into from
Jul 24, 2024

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.

This comment has been minimized.

@bzoracler
Copy link
Contributor Author

Fixes #17442

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
18 checks passed
@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