Debian Codegraph @

test-data/unit/plugins/customentry.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 MyPlugin(Plugin):
10 def get_function_hook(self, fullname: str) -> Callable[[FunctionContext], Type] | None:
11 if fullname == "__main__.f":
12 return my_hook
13 assert fullname
14 return None
15
16
17 def my_hook(ctx: FunctionContext) -> Type:
18 return ctx.api.named_generic_type("builtins.int", [])
19
20
21 def register(version: str) -> type[MyPlugin]:
22 return MyPlugin