Merge lp:~pyflakes-dev/pyflakes/0.6-del-import into lp:pyflakes

Proposed by Florent
Status: Merged
Merged at revision: 88
Proposed branch: lp:~pyflakes-dev/pyflakes/0.6-del-import
Merge into: lp:pyflakes
Diff against target: 80 lines (+16/-6) (has conflicts)
3 files modified
NEWS.txt (+5/-0)
pyflakes/checker.py (+10/-5)
pyflakes/test/test_imports.py (+1/-1)
Text conflict in NEWS.txt
Text conflict in pyflakes/checker.py
To merge this branch: bzr merge lp:~pyflakes-dev/pyflakes/0.6-del-import
Reviewer Review Type Date Requested Status
Pyflakes Dev Pending
Review via email: mp+157039@code.launchpad.net

Description of the change

Ready.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.txt'
2--- NEWS.txt 2013-04-02 17:33:38 +0000
3+++ NEWS.txt 2013-04-04 07:36:27 +0000
4@@ -6,9 +6,14 @@
5 comprehension in a conditional.
6 - Do not report redefinition of variable for generator expressions and
7 set or dict comprehensions.
8+<<<<<<< TREE
9 - Do not report undefined name when the code is protected with a
10 `NameError` exception handler.
11 - Fix issue with Turkish locale where `'i'.upper() == 'i'` in Python 2.
12+=======
13+ - Do not report redefinition of variable when unassigning a module imported
14+ for its side-effect.
15+>>>>>>> MERGE-SOURCE
16
17 0.6.1 (2013-01-29):
18 - Fix detection of variables in augmented assignments.
19
20=== modified file 'pyflakes/checker.py'
21--- pyflakes/checker.py 2013-04-02 17:33:38 +0000
22+++ pyflakes/checker.py 2013-04-04 07:36:27 +0000
23@@ -82,10 +82,6 @@
24 id(self))
25
26
27-class UnBinding(Binding):
28- """Created by the 'del' operator."""
29-
30-
31 class Importation(Binding):
32 """
33 A binding created by an import statement.
34@@ -387,6 +383,7 @@
35 self.report(messages.RedefinedInListComp,
36 node, value.name, existing.source)
37
38+<<<<<<< TREE
39 if isinstance(value, UnBinding):
40 try:
41 del self.scope[value.name]
42@@ -395,6 +392,11 @@
43 elif (isinstance(existing, Definition)
44 and not existing.used
45 and not self.differentForks(node, existing.source)):
46+=======
47+ if (isinstance(existing, Definition)
48+ and not existing.used
49+ and not self.differentForks(node, existing.source)):
50+>>>>>>> MERGE-SOURCE
51 self.report(messages.RedefinedWhileUnused,
52 node, value.name, existing.source)
53 else:
54@@ -491,7 +493,10 @@
55 if isinstance(self.scope, FunctionScope) and name in self.scope.globals:
56 self.scope.globals.remove(name)
57 else:
58- self.addBinding(node, UnBinding(name, node))
59+ try:
60+ del self.scope[name]
61+ except KeyError:
62+ self.report(messages.UndefinedName, node.lineno, name)
63
64 def handleChildren(self, tree):
65 for node in iter_child_nodes(tree):
66
67=== modified file 'pyflakes/test/test_imports.py'
68--- pyflakes/test/test_imports.py 2013-03-30 23:47:50 +0000
69+++ pyflakes/test/test_imports.py 2013-04-04 07:36:27 +0000
70@@ -19,10 +19,10 @@
71 def test_usedImport(self):
72 self.flakes('import fu; print(fu)')
73 self.flakes('from baz import fu; print(fu)')
74+ self.flakes('import fu; del fu')
75
76 def test_redefinedWhileUnused(self):
77 self.flakes('import fu; fu = 3', m.RedefinedWhileUnused)
78- self.flakes('import fu; del fu', m.RedefinedWhileUnused)
79 self.flakes('import fu; fu, bar = 3', m.RedefinedWhileUnused)
80 self.flakes('import fu; [fu, bar] = 3', m.RedefinedWhileUnused)
81

Subscribers

People subscribed via source and target branches

to all changes: