Skip to content

Commit dd6d786

Browse files
authored
Use callback protocol instead of mypy_extensions (#12701)
1 parent 33dbbd2 commit dd6d786

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

mypy/typeanal.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from mypy.backports import OrderedDict
77

88
from typing import Callable, List, Optional, Set, Tuple, Iterator, TypeVar, Iterable, Sequence
9-
from typing_extensions import Final
10-
from mypy_extensions import DefaultNamedArg
9+
from typing_extensions import Final, Protocol
1110

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

12421241
TypeVarLikeList = List[Tuple[str, TypeVarLikeExpr]]
12431242

1244-
# Mypyc doesn't support callback protocols yet.
1245-
MsgCallback = Callable[[str, Context, DefaultNamedArg(Optional[ErrorCode], 'code')], None]
1243+
1244+
class MsgCallback(Protocol):
1245+
def __call__(
1246+
self,
1247+
__msg: str,
1248+
__ctx: Context,
1249+
*,
1250+
code: Optional[ErrorCode] = None
1251+
) -> None: ...
12461252

12471253

12481254
def get_omitted_any(disallow_any: bool, fail: MsgCallback, note: MsgCallback,

0 commit comments

Comments
 (0)