python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
17.85k stars 2.74k forks source link

The implementation of TypeChecker.fail is incorrect #17442

Open delfick opened 1 week ago

delfick commented 1 week ago

Hi, it appears that TypeChecker.fail doesn't match the CheckerPluginInterface interface

https://github.com/python/mypy/blob/d39f0234a18762a9b261a28763c7bea706633ce7/mypy/plugin.py#L242

    @abstractmethod
    def fail(
        self, msg: str | ErrorMessage, ctx: Context, *, code: ErrorCode | None = None
    ) -> None:

https://github.com/python/mypy/blob/d39f0234a18762a9b261a28763c7bea706633ce7/mypy/checker.py#L7184

    def fail(
        self, msg: str | ErrorMessage, context: Context, *, code: ErrorCode | None = None
    ) -> None:

For some reason the implementation names ctx as context.