Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Re-apply 0c808db to not raise duplicate function warning for property decorators @prop.setter/deleter. #12

Open
wants to merge 3 commits into from
@xaka

You still use node.decorators_list here instead of prepared decorators. It fails on Python 2.5...

Fixed... thanks for catching that.

@tko

Just got bitten by this bug. Any reason not to accept the pull request?

@mahmoudimus

Hi, is there a reason this pull request is still not merged? It LGTM.

@natedub

I'd love to see this pulled as well.

@bernieke

+1

@sigmavirus24

Just FYI, this is in florentx/pyflakesand flakey. flakey's API is changing for a few reasons, and I'm going to be adding a couple command-line options to reflect that, so if you want a more traditional version, use @florentx's

@florentx

my branch is temporary: I'm working with the maintainers of upstream Pyflakes to merge more contributions and make it easier to contribute the patches upstream.
Within few weeks it should be better.

@florentx

Should be fixed with pyflakes 0.6.1 from PyPI, no?

Else, please open a ticket here: https://bugs.launchpad.net/pyflakes

@charlax

+1

@anthonyt anthonyt referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@retr0h

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 15, 2011
  1. @ervandew

    re-apply 0c808db: Don't warn about duplicate functions for property d…

    ervandew authored
    …ecorators @prop.setter and @prop.deleter.
  2. @ervandew
Commits on Mar 17, 2011
  1. @ervandew

    fix typo on retaining python 2.5 compatibility

    ervandew authored
    spotted by xaka
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 8 deletions.
  1. +17 −8 pyflakes/checker.py
View
25 pyflakes/checker.py
@@ -98,7 +98,7 @@ class Assignment(Binding):
class FunctionDefinition(Binding):
- pass
+ _property_decorator = False
@@ -353,8 +353,9 @@ def addBinding(self, loc, value, reportRedef=True):
'''
if (isinstance(self.scope.get(value.name), FunctionDefinition)
and isinstance(value, FunctionDefinition)):
- self.report(messages.RedefinedFunction,
- loc, value.name, self.scope[value.name].source)
+ if not value._property_decorator:
+ self.report(messages.RedefinedFunction,
+ loc, value.name, self.scope[value.name].source)
if not isinstance(self.scope, ClassScope):
for scope in self.scopeStack[::-1]:
@@ -512,12 +513,20 @@ def NAME(self, node):
def FUNCTIONDEF(self, node):
# the decorators attribute is called decorator_list as of Python 2.6
if hasattr(node, 'decorators'):
- for deco in node.decorators:
- self.handleNode(deco, node)
+ decorators = node.decorators
else:
- for deco in node.decorator_list:
- self.handleNode(deco, node)
- self.addBinding(node, FunctionDefinition(node.name, node))
+ decorators = node.decorator_list
+
+ for deco in decorators:
+ self.handleNode(deco, node)
+
+ # Check for property decorator
+ func_def = FunctionDefinition(node.name, node)
+ for decorator in decorators:
+ if getattr(decorator, 'attr', None) in ('setter', 'deleter'):
+ func_def._property_decorator = True
+
+ self.addBinding(node, func_def)
self.LAMBDA(node)
def LAMBDA(self, node):
Something went wrong with that request. Please try again.