Skip to content

Commit

Permalink
Add minimal plug-in
Browse files Browse the repository at this point in the history
This plug-in is invoked twice, when analyzing `target.py`. Since it
always returns None, all it's results are ignored.
  • Loading branch information
SoloJacobs committed Aug 7, 2022
1 parent ae8fd6c commit 82d1ded
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ warn_return_any = True
no_implicit_reexport = True
strict_equality = True
strict_concatenate = True

plugins = src/plugin.py
13 changes: 13 additions & 0 deletions src/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from mypy.plugin import Plugin


class CustomPlugin(Plugin):
def get_type_analyze_hook(self, fullname: str) -> None:
# see explanation below
if fullname.startswith("sol.GetItem"):
print(fullname)


def plugin(version: str) -> type[CustomPlugin]:
# ignore version argument if the plugin works with all mypy versions.
return CustomPlugin
6 changes: 4 additions & 2 deletions src/target.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from sol import GetItem

reveal_type(GetItem())
# reveal_type(GetItem())

def f():
_: GetItem

def f(_: GetItem) -> None:
...

0 comments on commit 82d1ded

Please sign in to comment.