300 MOD = POW = LSHIFT = RSHIFT = BITOR = BITXOR = BITAND = FLOORDIV = \ |
300 MOD = POW = LSHIFT = RSHIFT = BITOR = BITXOR = BITAND = FLOORDIV = \ |
301 INVERT = NOT = UADD = USUB = EQ = NOTEQ = LT = LTE = GT = GTE = IS = \ |
301 INVERT = NOT = UADD = USUB = EQ = NOTEQ = LT = LTE = GT = GTE = IS = \ |
302 ISNOT = IN = NOTIN = ignore |
302 ISNOT = IN = NOTIN = ignore |
303 |
303 |
304 # "stmt" type nodes |
304 # "stmt" type nodes |
305 RETURN = DELETE = PRINT = WHILE = IF = WITH = RAISE = TRYEXCEPT = \ |
305 RETURN = DELETE = PRINT = WHILE = IF = WITH = WITHITEM = RAISE = \ |
306 TRYFINALLY = ASSERT = EXEC = EXPR = handleChildren |
306 TRYEXCEPT = TRYFINALLY = ASSERT = EXEC = EXPR = handleChildren |
307 |
307 |
308 # "expr" type nodes |
308 # "expr" type nodes |
309 BOOLOP = BINOP = UNARYOP = IFEXP = DICT = SET = YIELD = COMPARE = \ |
309 BOOLOP = BINOP = UNARYOP = IFEXP = DICT = SET = YIELD = COMPARE = \ |
310 CALL = REPR = ATTRIBUTE = SUBSCRIPT = LIST = TUPLE = handleChildren |
310 CALL = REPR = ATTRIBUTE = SUBSCRIPT = LIST = TUPLE = handleChildren |
311 |
311 |
324 with the binding; if None, the binding is deleted if it exists |
324 with the binding; if None, the binding is deleted if it exists |
325 @param reportRedef flag indicating if rebinding while unused will be |
325 @param reportRedef flag indicating if rebinding while unused will be |
326 reported (boolean) |
326 reported (boolean) |
327 ''' |
327 ''' |
328 if (isinstance(self.scope.get(value.name), FunctionDefinition) |
328 if (isinstance(self.scope.get(value.name), FunctionDefinition) |
329 and isinstance(value, FunctionDefinition)): |
329 and isinstance(value, FunctionDefinition) |
|
330 and not self.scope.get(value.name).is_property |
|
331 and not value.is_property): |
330 self.report(messages.RedefinedFunction, |
332 self.report(messages.RedefinedFunction, |
331 lineno, value.name, self.scope[value.name].source.lineno) |
333 lineno, value.name, self.scope[value.name].source.lineno) |
332 |
334 |
333 if not isinstance(self.scope, ClassScope): |
335 if not isinstance(self.scope, ClassScope): |
334 for scope in self.scopeStack[::-1]: |
336 for scope in self.scopeStack[::-1]: |
485 # arguments, but these aren't dispatched through here |
487 # arguments, but these aren't dispatched through here |
486 raise RuntimeError( |
488 raise RuntimeError( |
487 "Got impossible expression context: {0:r}".format(node.ctx,)) |
489 "Got impossible expression context: {0:r}".format(node.ctx,)) |
488 |
490 |
489 def FUNCTIONDEF(self, node): |
491 def FUNCTIONDEF(self, node): |
|
492 is_property = False |
490 if hasattr(node, "decorator_list"): |
493 if hasattr(node, "decorator_list"): |
491 for decorator in node.decorator_list: |
494 for decorator in node.decorator_list: |
492 self.handleNode(decorator, node) |
495 self.handleNode(decorator, node) |
493 self.addBinding(node.lineno, FunctionDefinition(node.name, node)) |
496 if getattr(decorator, 'id', None) == 'property': |
|
497 is_property = True |
|
498 if getattr(decorator, 'attr', None) in ('setter', 'deleter'): |
|
499 is_property = True |
|
500 funcdef = FunctionDefinition(node.name, node) |
|
501 funcdef.is_property = is_property |
|
502 self.addBinding(node.lineno, funcdef) |
494 self.LAMBDA(node) |
503 self.LAMBDA(node) |
495 |
504 |
496 def LAMBDA(self, node): |
505 def LAMBDA(self, node): |
497 for default in node.args.defaults + node.args.kw_defaults: |
506 for default in node.args.defaults + node.args.kw_defaults: |
498 self.handleNode(default, node) |
507 self.handleNode(default, node) |