def analyse_external_member_access(self, member, base_type, context): """Analyse member access that is external, i.e. it cannot refer to private definitions. Return the result type. """ # TODO remove; no private definitions in mypy return analyse_member_access(member, base_type, context, False, False, self.chk.tuple_type(), self.msg)
def analyse_super(self, e, is_lvalue): """Type check a super expression.""" if e.info and e.info.base: return analyse_member_access(e.name, self_type(e.info), e, is_lvalue, True, self.chk.tuple_type(), self.msg, e.info.base) else: # Invalid super. This has been reported by the semantic analyser. return Any()
def analyse_ordinary_member_access(self, e, is_lvalue): """Analyse member expression or member lvalue.""" if e.kind is not None: # This is a reference to a module attribute. return self.analyse_ref_expr(e) else: # This is a reference to a non-module attribute. return analyse_member_access(e.name, self.accept(e.expr), e, is_lvalue, False, self.chk.tuple_type(), self.msg)
callable.bound_vars + bound_vars, callable.line, callable.repr) Typ visit_member_expr(self, MemberExpr e): """Visit member expression (of form e.id).""" return self.analyse_ordinary_member_access(e, False) Typ analyse_ordinary_member_access(self, MemberExpr e, bool is_lvalue): """Analyse member expression or member lvalue.""" if e.kind is not None: # This is a reference to a module attribute. return self.analyse_ref_expr(e) else: # This is a reference to a non-module attribute. return analyse_member_access(e.name, self.accept(e.expr), e, is_lvalue, False, self.chk.tuple_type(), self.msg) Typ analyse_external_member_access(self, str member, Typ base_type, Context context): """Analyse member access that is external, i.e. it cannot refer to private definitions. Return the result type. """ # TODO remove; no private definitions in mypy return analyse_member_access(member, base_type, context, False, False, self.chk.tuple_type(), self.msg) Typ visit_int_expr(self, IntExpr e): """Type check an integer literal (trivial).""" return self.named_type('builtins.int')
""" # FIX overloading, default args / varargs, keyword args info = tdef.info if '__init__' not in info.methods and (tdef.is_generic() or info.base.is_generic()): # Generic class with no explicit __init__ method # (i.e. __init__ inherited from superclass). Generate a # wrapper that initializes type variable slots and calls # the superclass __init__ method. selftype = self_type(info) callee_type = (Callable)analyse_member_access( '__init__', selftype, None, False, True, None, None, info.base) # Now the callee type may contain the type variables of a # grandparent as bound type variables, but we want the # type variables of the parent class. Explicitly set the # bound type variables. callee_type = self.fix_bound_init_tvars(callee_type, map_instance_to_supertype(selftype, info.base)) super_init = (FuncDef)info.base.get_method('__init__') # Build argument list. args = [Var('self')] for i in range(1, len(super_init.args)): args.append(Var(super_init.args[i].name()))