Type checker plugin that is enabled by default.
| 94 | |
| 95 | |
| 96 | class DefaultPlugin(Plugin): |
| 97 | """Type checker plugin that is enabled by default.""" |
| 98 | |
| 99 | def get_function_hook(self, fullname: str) -> Callable[[FunctionContext], Type] | None: |
| 100 | if fullname == "_ctypes.Array": |
| 101 | return array_constructor_callback |
| 102 | elif fullname == "functools.singledispatch": |
| 103 | return create_singledispatch_function_callback |
| 104 | elif fullname == "functools.partial": |
| 105 | return partial_new_callback |
| 106 | elif fullname == "enum.member": |
| 107 | return enum_member_callback |
| 108 | elif fullname == "builtins.len": |
| 109 | return len_callback |
| 110 | return None |
| 111 | |
| 112 | def get_function_signature_hook( |
| 113 | self, fullname: str |
| 114 | ) -> Callable[[FunctionSigContext], FunctionLike] | None: |
| 115 | if fullname in ("attr.evolve", "attrs.evolve", "attr.assoc", "attrs.assoc"): |
| 116 | return evolve_function_sig_callback |
| 117 | elif fullname in ("attr.fields", "attrs.fields"): |
| 118 | return fields_function_sig_callback |
| 119 | elif fullname == "dataclasses.replace": |
| 120 | return replace_function_sig_callback |
| 121 | return None |
| 122 | |
| 123 | def get_method_signature_hook( |
| 124 | self, fullname: str |
| 125 | ) -> Callable[[MethodSigContext], FunctionLike] | None: |
| 126 | if fullname == "typing.Mapping.get": |
| 127 | return typed_dict_get_signature_callback |
| 128 | elif fullname in TD_SETDEFAULT_NAMES: |
| 129 | return typed_dict_setdefault_signature_callback |
| 130 | elif fullname in TD_POP_NAMES: |
| 131 | return typed_dict_pop_signature_callback |
| 132 | elif fullname == "_ctypes.Array.__setitem__": |
| 133 | return array_setitem_callback |
| 134 | elif fullname == SINGLEDISPATCH_CALLABLE_CALL_METHOD: |
| 135 | return call_singledispatch_function_callback |
| 136 | elif fullname in TD_UPDATE_METHOD_NAMES: |
| 137 | return typed_dict_update_signature_callback |
| 138 | return None |
| 139 | |
| 140 | def get_method_hook(self, fullname: str) -> Callable[[MethodContext], Type] | None: |
| 141 | if fullname == "typing.Mapping.get": |
| 142 | return typed_dict_get_callback |
| 143 | elif fullname == "builtins.int.__pow__": |
| 144 | return int_pow_callback |
| 145 | elif fullname == "builtins.int.__neg__": |
| 146 | return int_neg_callback |
| 147 | elif fullname == "builtins.int.__pos__": |
| 148 | return int_pos_callback |
| 149 | elif fullname in ("builtins.tuple.__mul__", "builtins.tuple.__rmul__"): |
| 150 | return tuple_mul_callback |
| 151 | elif fullname in TD_SETDEFAULT_NAMES: |
| 152 | return typed_dict_setdefault_callback |
| 153 | elif fullname in TD_POP_NAMES: |
no outgoing calls
no test coverage detected
searching dependent graphs…