Skip to content

Use callback protocol instead of mypy_extensions #12701

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

Merged
merged 3 commits into from
May 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from mypy.backports import OrderedDict

from typing import Callable, List, Optional, Set, Tuple, Iterator, TypeVar, Iterable, Sequence
from typing_extensions import Final
from mypy_extensions import DefaultNamedArg
from typing_extensions import Final, Protocol

from mypy.messages import MessageBuilder, quote_type_string, format_type_bare
from mypy.options import Options
Expand Down Expand Up @@ -1241,8 +1240,15 @@ def set_allow_param_spec_literals(self, to: bool) -> Iterator[None]:

TypeVarLikeList = List[Tuple[str, TypeVarLikeExpr]]

# Mypyc doesn't support callback protocols yet.
MsgCallback = Callable[[str, Context, DefaultNamedArg(Optional[ErrorCode], 'code')], None]

class MsgCallback(Protocol):
def __call__(
self,
__msg: str,
__ctx: Context,
*,
code: Optional[ErrorCode] = None
) -> None: ...


def get_omitted_any(disallow_any: bool, fail: MsgCallback, note: MsgCallback,
Expand Down