2121from mypy .nodes import ARG_NAMED_OPT
2222from mypy .plugin import MethodSigContext , Plugin
2323from mypy .typeops import bind_self
24- from mypy .types import CallableType , NoneType
24+ from mypy .types import CallableType , NoneType , UnionType
2525
2626
2727class SynapsePlugin (Plugin ):
@@ -72,13 +72,20 @@ def cached_function_method_signature(ctx: MethodSigContext) -> CallableType:
7272
7373 # Third, we add an optional "on_invalidate" argument.
7474 #
75- # This is a callable which accepts no input and returns nothing.
76- calltyp = CallableType (
77- arg_types = [],
78- arg_kinds = [],
79- arg_names = [],
80- ret_type = NoneType (),
81- fallback = ctx .api .named_generic_type ("builtins.function" , []),
75+ # This is a either
76+ # - a callable which accepts no input and returns nothing, or
77+ # - None.
78+ calltyp = UnionType (
79+ [
80+ NoneType (),
81+ CallableType (
82+ arg_types = [],
83+ arg_kinds = [],
84+ arg_names = [],
85+ ret_type = NoneType (),
86+ fallback = ctx .api .named_generic_type ("builtins.function" , []),
87+ ),
88+ ]
8289 )
8390
8491 arg_types .append (calltyp )
@@ -95,7 +102,7 @@ def cached_function_method_signature(ctx: MethodSigContext) -> CallableType:
95102
96103
97104def plugin (version : str ) -> Type [SynapsePlugin ]:
98- # This is the entry point of the plugin, and let's us deal with the fact
105+ # This is the entry point of the plugin, and lets us deal with the fact
99106 # that the mypy plugin interface is *not* stable by looking at the version
100107 # string.
101108 #
0 commit comments