Debian Codegraph @

test-data/unit/plugins/plugin2.py

raw
1 from __future__ import annotations
2
3 from typing import Callable
4
5 from mypy.plugin import FunctionContext, Plugin
6 from mypy.types import Type
7
8
9 class Plugin2(Plugin):
10 def get_function_hook(self, fullname: str) -> Callable[[FunctionContext], Type] | None:
11 if fullname in ("__main__.f", "__main__.g"):
12 return str_hook
13 return None
14
15
16 def str_hook(ctx: FunctionContext) -> Type:
17 return ctx.api.named_generic_type("builtins.str", [])
18
19
20 def plugin(version: str) -> type[Plugin2]:
21 return Plugin2