Skip to content

Commit cd7913a

Browse files
committed
typing
1 parent c75ec24 commit cd7913a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pynamodb_mypy/plugin.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ def get_method_signature_hook(self, fullname: str
1919
) -> Optional[Callable[[mypy.plugin.MethodSigContext], mypy.types.CallableType]]:
2020
class_name, method_name = fullname.rsplit('.', 1)
2121
sym = self.lookup_fully_qualified(class_name)
22-
if sym and _is_attribute_type_node(sym.node):
22+
if sym is not None and sym.node is not None and _is_attribute_type_node(sym.node):
2323
if method_name == '__get__':
2424
return _get_method_sig_hook
2525
elif method_name == '__set__':
2626
return _set_method_sig_hook
2727
return None
2828

2929

30-
def _is_attribute_type_node(type_node: mypy.nodes.TypeInfo) -> bool:
31-
return any(base.type.fullname == ATTR_FULL_NAME for base in type_node.bases)
30+
def _is_attribute_type_node(node: mypy.nodes.Node) -> bool:
31+
return (
32+
isinstance(node, mypy.nodes.TypeInfo) and
33+
any(base.type.fullname == ATTR_FULL_NAME for base in node.bases)
34+
)
3235

3336

3437
def _attribute_marked_as_nullable(t: mypy.types.Instance) -> mypy.types.Instance:

0 commit comments

Comments
 (0)