Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Jan 26, 2019
1 parent b61291c commit c315612
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/mypy_zope/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from mypy.nodes import (
Decorator, Var, Argument, FuncDef, CallExpr, RefExpr, Expression,
ClassDef, Statement, Block, IndexExpr,
ClassDef, Statement, Block, IndexExpr, MemberExpr,
MDEF, ARG_POS, ARG_OPT
)

Expand Down Expand Up @@ -104,19 +104,22 @@ def get_method_signature_hook(self, fullname: str
def get_method_hook(self, fullname: str
) -> Optional[Callable[[MethodContext], Type]]:
# print(f"get_method_hook: {fullname}")
def analyze(method_ctx: MethodContext) -> Type:
methodname = fullname.split('.')[-1]
if methodname in ('providedBy', 'implementedBy'):
if methodname == 'providedBy':

methodname = fullname.split('.')[-1]
if methodname in ('providedBy', 'implementedBy'):
def analyze(method_ctx: MethodContext) -> Type:
assert isinstance(method_ctx.context, CallExpr)
assert isinstance(method_ctx.context.callee, MemberExpr)
if method_ctx.context.callee.name == 'providedBy':
method_ctx.context.callee.fullname = 'builtins.isinstance'
else:
method_ctx.context.callee.fullname = 'builtins.issubclass'
method_ctx.context.args = [method_ctx.args[0][0],
method_ctx.context.callee.expr]

return method_ctx.default_return_type

return analyze
return method_ctx.default_return_type
return analyze
return None

def get_attribute_hook(self, fullname: str
) -> Optional[Callable[[AttributeContext], Type]]:
Expand Down

0 comments on commit c315612

Please sign in to comment.