Merge lp:~pyflakes-dev/pyflakes/1107587-add-builtins into lp:pyflakes

Proposed by Florent
Status: Merged
Merged at revision: 63
Proposed branch: lp:~pyflakes-dev/pyflakes/1107587-add-builtins
Merge into: lp:pyflakes
Diff against target: 42 lines (+6/-2)
2 files modified
NEWS.txt (+1/-0)
pyflakes/checker.py (+5/-2)
To merge this branch: bzr merge lp:~pyflakes-dev/pyflakes/1107587-add-builtins
Reviewer Review Type Date Requested Status
Pyflakes Dev Pending
Review via email: mp+145125@code.launchpad.net

Description of the change

Add flexibility for the magic built-ins.

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
=== modified file 'NEWS.txt'
--- NEWS.txt 2013-01-27 15:09:36 +0000
+++ NEWS.txt 2013-01-28 07:35:32 +0000
@@ -6,6 +6,7 @@
6 - Allow function redefinition for modern property construction via6 - Allow function redefinition for modern property construction via
7 property.setter/deleter.7 property.setter/deleter.
8 - Do not report undefined name in __all__ if import * is used.8 - Do not report undefined name in __all__ if import * is used.
9 - Support specifying additional built-ins in `Checker` constructor.
9 - Handle problems with the encoding of source files.10 - Handle problems with the encoding of source files.
10 - Remove dependency on Twisted for the tests.11 - Remove dependency on Twisted for the tests.
11 - Support `python setup.py test` and `python setup.py develop`.12 - Support `python setup.py test` and `python setup.py develop`.
1213
=== modified file 'pyflakes/checker.py'
--- pyflakes/checker.py 2013-01-27 15:04:53 +0000
+++ pyflakes/checker.py 2013-01-28 07:35:32 +0000
@@ -187,13 +187,16 @@
187187
188 nodeDepth = 0188 nodeDepth = 0
189 traceTree = False189 traceTree = False
190 builtIns = set(dir(builtins)) | set(_MAGIC_GLOBALS)
190191
191 def __init__(self, tree, filename='(none)'):192 def __init__(self, tree, filename='(none)', builtins=None):
192 self._deferredFunctions = []193 self._deferredFunctions = []
193 self._deferredAssignments = []194 self._deferredAssignments = []
194 self.deadScopes = []195 self.deadScopes = []
195 self.messages = []196 self.messages = []
196 self.filename = filename197 self.filename = filename
198 if builtins:
199 self.builtIns = self.builtIns.union(builtins)
197 self.scopeStack = [ModuleScope()]200 self.scopeStack = [ModuleScope()]
198 self.futuresAllowed = True201 self.futuresAllowed = True
199 self.handleChildren(tree)202 self.handleChildren(tree)
@@ -351,7 +354,7 @@
351 try:354 try:
352 self.scopeStack[0][name].used = (self.scope, node.lineno)355 self.scopeStack[0][name].used = (self.scope, node.lineno)
353 except KeyError:356 except KeyError:
354 if ((not hasattr(builtins, name)) and name not in _MAGIC_GLOBALS and not importStarred):357 if not importStarred and name not in self.builtIns:
355 if (os.path.basename(self.filename) == '__init__.py' and name == '__path__'):358 if (os.path.basename(self.filename) == '__init__.py' and name == '__path__'):
356 # the special name __path__ is valid only in packages359 # the special name __path__ is valid only in packages
357 pass360 pass

Subscribers

People subscribed via source and target branches

to all changes: