commit python-pyflakes for openSUSE:Factory
Hello community, here is the log from the commit of package python-pyflakes for openSUSE:Factory checked in at 2015-07-02 22:44:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pyflakes (Old) and /work/SRC/openSUSE:Factory/.python-pyflakes.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-pyflakes" Changes: -------- --- /work/SRC/openSUSE:Factory/python-pyflakes/python-pyflakes.changes 2014-04-13 13:17:09.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-pyflakes.new/python-pyflakes.changes 2015-07-02 22:44:58.000000000 +0200 @@ -1,0 +2,16 @@ +Mon Jun 22 15:15:47 UTC 2015 - tbechtold@suse.com + +- update to 0.9.2: + - Fix a traceback when a global is defined in one scope, and used in another. + - Update NEWS.txt to include 0.9.0, which had been forgotten. + - Exit gracefully, not with a traceback, on SIGINT and SIGPIPE. + - Fix incorrect report of undefined name when using lambda expressions in + generator expressions. + - Don't crash on DOS line endings on Windows and Python 2.6. + - Don't report an undefined name if the 'del' which caused a name to become + undefined is only conditionally executed. + - Properly handle differences in list comprehension scope in Python 3. + - Improve handling of edge cases around 'global' defined variables. + - Report an error for 'return' outside a function. + +------------------------------------------------------------------- Old: ---- pyflakes-0.8.1.tar.gz New: ---- pyflakes-0.9.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pyflakes.spec ++++++ --- /var/tmp/diff_new_pack.H7nv9x/_old 2015-07-02 22:44:59.000000000 +0200 +++ /var/tmp/diff_new_pack.H7nv9x/_new 2015-07-02 22:44:59.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-pyflakes # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: python-pyflakes -Version: 0.8.1 +Version: 0.9.2 Release: 0 Url: https://launchpad.net/pyflakes Summary: Passive checker of Python programs ++++++ pyflakes-0.8.1.tar.gz -> pyflakes-0.9.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/AUTHORS new/pyflakes-0.9.2/AUTHORS --- old/pyflakes-0.8.1/AUTHORS 2014-03-22 13:31:07.000000000 +0100 +++ new/pyflakes-0.9.2/AUTHORS 2015-04-17 14:48:24.000000000 +0200 @@ -1,4 +1,3 @@ - Contributors ------------ @@ -18,3 +17,6 @@ * Marcin Cieślak * Steven Myint * Ignas Mikalajūnas + +See also the contributors list on GitHub: +https://github.com/pyflakes/pyflakes/graphs/contributors diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/NEWS.txt new/pyflakes-0.9.2/NEWS.txt --- old/pyflakes-0.8.1/NEWS.txt 2014-03-30 20:46:51.000000000 +0200 +++ new/pyflakes-0.9.2/NEWS.txt 2015-06-17 12:19:30.000000000 +0200 @@ -1,3 +1,20 @@ +0.9.2 (2015-06-17): + - Fix a traceback when a global is defined in one scope, and used in another. + +0.9.1 (2015-06-09): + - Update NEWS.txt to include 0.9.0, which had been forgotten. + +0.9.0 (2015-05-31): + - Exit gracefully, not with a traceback, on SIGINT and SIGPIPE. + - Fix incorrect report of undefined name when using lambda expressions in + generator expressions. + - Don't crash on DOS line endings on Windows and Python 2.6. + - Don't report an undefined name if the 'del' which caused a name to become + undefined is only conditionally executed. + - Properly handle differences in list comprehension scope in Python 3. + - Improve handling of edge cases around 'global' defined variables. + - Report an error for 'return' outside a function. + 0.8.1 (2014-03-30): - Detect the declared encoding in Python 3. - Do not report redefinition of import in a local scope, if the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/PKG-INFO new/pyflakes-0.9.2/PKG-INFO --- old/pyflakes-0.8.1/PKG-INFO 2014-03-30 20:53:07.000000000 +0200 +++ new/pyflakes-0.9.2/PKG-INFO 2015-06-17 12:22:13.000000000 +0200 @@ -1,10 +1,10 @@ Metadata-Version: 1.1 Name: pyflakes -Version: 0.8.1 +Version: 0.9.2 Summary: passive checker of Python programs -Home-page: https://launchpad.net/pyflakes -Author: Florent Xicluna -Author-email: pyflakes-dev@lists.launchpad.net +Home-page: https://github.com/pyflakes/pyflakes +Author: A lot of people +Author-email: code-quality@python.org License: MIT Description: ======== Pyflakes @@ -16,10 +16,11 @@ parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster. - It is `available on PyPI http://pypi.python.org/pypi/pyflakes`_ + It is `available on PyPI https://pypi.python.org/pypi/pyflakes`_ and it supports all active versions of Python from 2.5 to 3.4. + Installation ------------ @@ -28,11 +29,42 @@ $ pip install --upgrade pyflakes + Useful tips: + + * Be sure to install it for a version of Python which is compatible + with your codebase: for Python 2, ``pip2 install pyflakes`` and for + Python3, ``pip3 install pyflakes``. + + * You can also invoke Pyflakes with ``python3 -m pyflakes .`` or + ``python2 -m pyflakes .`` if you have it installed for both versions. + + * If you require more options and more flexibility, you could give a + look to Flake8_ too. + + + Design Principles + ----------------- + Pyflakes makes a simple promise: it will never complain about style, + and it will try very, very hard to never emit false positives. + + Pyflakes is also faster than Pylint_ + or Pychecker_. This is + largely because Pyflakes only examines the syntax tree of each file + individually. As a consequence, Pyflakes is more limited in the + types of things it can check. + + If you like Pyflakes but also want styleistic checks, you want + flake8_, which combines + Pyflakes with style checks against + `PEP 8`_ and adds + per-project configuration ability. + + Mailing-list ------------ Share your feedback and ideas: `subscribe to the mailing-list - http://mail.python.org/mailman/listinfo/code-quality`_ + https://mail.python.org/mailman/listinfo/code-quality`_ .. image:: https://api.travis-ci.org/pyflakes/pyflakes.png @@ -43,6 +75,11 @@ :target: https://pypi.python.org/pypi/pyflakes :alt: Wheel Status + .. _Pylint: http://www.pylint.org/ + .. _flake8: https://pypi.python.org/pypi/flake8 + .. _`PEP 8`: http://legacy.python.org/dev/peps/pep-0008/ + .. _Pychecker: http://pychecker.sourceforge.net/ + Platform: UNKNOWN Classifier: Development Status :: 6 - Mature Classifier: Environment :: Console diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/README.rst new/pyflakes-0.9.2/README.rst --- old/pyflakes-0.8.1/README.rst 2014-03-30 20:30:36.000000000 +0200 +++ new/pyflakes-0.9.2/README.rst 2014-10-29 15:41:06.000000000 +0100 @@ -8,10 +8,11 @@ parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster. -It is `available on PyPI http://pypi.python.org/pypi/pyflakes`_ +It is `available on PyPI https://pypi.python.org/pypi/pyflakes`_ and it supports all active versions of Python from 2.5 to 3.4. + Installation ------------ @@ -20,11 +21,42 @@ $ pip install --upgrade pyflakes +Useful tips: + +* Be sure to install it for a version of Python which is compatible + with your codebase: for Python 2, ``pip2 install pyflakes`` and for + Python3, ``pip3 install pyflakes``. + +* You can also invoke Pyflakes with ``python3 -m pyflakes .`` or + ``python2 -m pyflakes .`` if you have it installed for both versions. + +* If you require more options and more flexibility, you could give a + look to Flake8_ too. + + +Design Principles +----------------- +Pyflakes makes a simple promise: it will never complain about style, +and it will try very, very hard to never emit false positives. + +Pyflakes is also faster than Pylint_ +or Pychecker_. This is +largely because Pyflakes only examines the syntax tree of each file +individually. As a consequence, Pyflakes is more limited in the +types of things it can check. + +If you like Pyflakes but also want styleistic checks, you want +flake8_, which combines +Pyflakes with style checks against +`PEP 8`_ and adds +per-project configuration ability. + + Mailing-list ------------ Share your feedback and ideas: `subscribe to the mailing-list -http://mail.python.org/mailman/listinfo/code-quality`_ +https://mail.python.org/mailman/listinfo/code-quality`_ .. image:: https://api.travis-ci.org/pyflakes/pyflakes.png @@ -34,3 +66,8 @@ .. image:: https://pypip.in/wheel/pyflakes/badge.png :target: https://pypi.python.org/pypi/pyflakes :alt: Wheel Status + +.. _Pylint: http://www.pylint.org/ +.. _flake8: https://pypi.python.org/pypi/flake8 +.. _`PEP 8`: http://legacy.python.org/dev/peps/pep-0008/ +.. _Pychecker: http://pychecker.sourceforge.net/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/__init__.py new/pyflakes-0.9.2/pyflakes/__init__.py --- old/pyflakes-0.8.1/pyflakes/__init__.py 2014-03-30 16:56:10.000000000 +0200 +++ new/pyflakes-0.9.2/pyflakes/__init__.py 2015-06-17 12:18:24.000000000 +0200 @@ -1,2 +1 @@ - -__version__ = '0.8.1' +__version__ = '0.9.2' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/api.py new/pyflakes-0.9.2/pyflakes/api.py --- old/pyflakes-0.8.1/pyflakes/api.py 2014-03-29 12:07:31.000000000 +0100 +++ new/pyflakes-0.9.2/pyflakes/api.py 2015-04-17 16:50:37.000000000 +0200 @@ -6,7 +6,6 @@ import sys import os import _ast -from optparse import OptionParser from pyflakes import checker, __version__ from pyflakes import reporter as modReporter @@ -74,7 +73,16 @@ if reporter is None: reporter = modReporter._makeDefaultReporter() try: - with open(filename, 'rb') as f: + # in Python 2.6, compile() will choke on \r\n line endings. In later + # versions of python it's smarter, and we want binary mode to give + # compile() the best opportunity to do the right thing WRT text + # encodings. + if sys.version_info < (2, 7): + mode = 'rU' + else: + mode = 'rb' + + with open(filename, mode) as f: codestr = f.read() if sys.version_info < (2, 7): codestr += '\n' # Work around for Python <= 2.6 @@ -122,8 +130,42 @@ return warnings +def _exitOnSignal(sigName, message): + """Handles a signal with sys.exit. + + Some of these signals (SIGPIPE, for example) don't exist or are invalid on + Windows. So, ignore errors that might arise. + """ + import signal + + try: + sigNumber = getattr(signal, sigName) + except AttributeError: + # the signal constants defined in the signal module are defined by + # whether the C library supports them or not. So, SIGPIPE might not + # even be defined. + return + + def handler(sig, f): + sys.exit(message) + + try: + signal.signal(sigNumber, handler) + except ValueError: + # It's also possible the signal is defined, but then it's invalid. In + # this case, signal.signal raises ValueError. + pass + + def main(prog=None): - parser = OptionParser(prog=prog, version=__version__) + """Entry point for the script "pyflakes".""" + import optparse + + # Handle "Keyboard Interrupt" and "Broken pipe" gracefully + _exitOnSignal('SIGINT', '... stopped') + _exitOnSignal('SIGPIPE', 1) + + parser = optparse.OptionParser(prog=prog, version=__version__) (__, args) = parser.parse_args() reporter = modReporter._makeDefaultReporter() if args: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/checker.py new/pyflakes-0.9.2/pyflakes/checker.py --- old/pyflakes-0.8.1/pyflakes/checker.py 2014-03-30 19:43:56.000000000 +0200 +++ new/pyflakes-0.9.2/pyflakes/checker.py 2015-06-17 12:17:45.000000000 +0200 @@ -471,7 +471,7 @@ return scopes = [scope for scope in self.scopeStack[:-1] - if isinstance(scope, (FunctionScope, ModuleScope))] + if isinstance(scope, (FunctionScope, ModuleScope, GeneratorScope))] if isinstance(self.scope, GeneratorScope) and scopes[-1] != self.scopeStack[-2]: scopes.append(self.scopeStack[-2]) @@ -531,9 +531,27 @@ self.addBinding(node, binding) def handleNodeDelete(self, node): + + def on_conditional_branch(): + """ + Return `True` if node is part of a conditional body. + """ + current = getattr(node, 'parent', None) + while current: + if isinstance(current, (ast.If, ast.While, ast.IfExp)): + return True + current = getattr(current, 'parent', None) + return False + name = getNodeName(node) if not name: return + + if on_conditional_branch(): + # We can not predict if this conditional branch is going to + # be executed. + return + if isinstance(self.scope, FunctionScope) and name in self.scope.globals: self.scope.globals.remove(name) else: @@ -654,14 +672,36 @@ EQ = NOTEQ = LT = LTE = GT = GTE = IS = ISNOT = IN = NOTIN = ignore # additional node types - LISTCOMP = COMPREHENSION = KEYWORD = handleChildren + COMPREHENSION = KEYWORD = handleChildren def GLOBAL(self, node): """ Keep track of globals declarations. """ - if isinstance(self.scope, FunctionScope): - self.scope.globals.update(node.names) + # In doctests, the global scope is an anonymous function at index 1. + global_scope_index = 1 if self.withDoctest else 0 + global_scope = self.scopeStack[global_scope_index] + + # Ignore 'global' statement in global scope. + if self.scope is not global_scope: + + # One 'global' statement can bind multiple (comma-delimited) names. + for node_name in node.names: + node_value = Assignment(node_name, node) + + # Remove UndefinedName messages already reported for this name. + self.messages = [ + m for m in self.messages if not + isinstance(m, messages.UndefinedName) and not + m.message_args[0] == node_name] + + # Bind name to global scope if it doesn't exist already. + global_scope.setdefault(node_name, node_value) + + # Bind name to non-global scopes, but as already "used". + node_value.used = (global_scope, node) + for scope in self.scopeStack[global_scope_index + 1:]: + scope[node_name] = node_value NONLOCAL = GLOBAL @@ -670,6 +710,8 @@ self.handleChildren(node) self.popScope() + LISTCOMP = handleChildren if PY2 else GENERATOREXP + DICTCOMP = SETCOMP = GENERATOREXP def NAME(self, node): @@ -693,7 +735,15 @@ raise RuntimeError("Got impossible expression context: %r" % (node.ctx,)) def RETURN(self, node): - if node.value and not self.scope.returnValue: + if isinstance(self.scope, ClassScope): + self.report(messages.ReturnOutsideFunction, node) + return + + if ( + node.value and + hasattr(self.scope, 'returnValue') and + not self.scope.returnValue + ): self.scope.returnValue = node.value self.handleNode(node.value, node) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/messages.py new/pyflakes-0.9.2/pyflakes/messages.py --- old/pyflakes-0.8.1/pyflakes/messages.py 2014-03-22 13:31:07.000000000 +0100 +++ new/pyflakes-0.9.2/pyflakes/messages.py 2015-04-17 13:41:05.000000000 +0200 @@ -100,14 +100,6 @@ self.message_args = (name,) -class Redefined(Message): - message = 'redefinition of %r from line %r' - - def __init__(self, filename, loc, name, orig_loc): - Message.__init__(self, filename, loc) - self.message_args = (name, orig_loc.lineno) - - class LateFutureImport(Message): message = 'future import(s) %r after other statements' @@ -133,3 +125,10 @@ Indicates a return statement with arguments inside a generator. """ message = '\'return\' with argument inside generator' + + +class ReturnOutsideFunction(Message): + """ + Indicates a return statement outside of a function/method. + """ + message = '\'return\' outside function' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/scripts/pyflakes.py new/pyflakes-0.9.2/pyflakes/scripts/pyflakes.py --- old/pyflakes-0.8.1/pyflakes/scripts/pyflakes.py 2014-01-07 02:12:57.000000000 +0100 +++ new/pyflakes-0.9.2/pyflakes/scripts/pyflakes.py 2014-09-23 16:08:41.000000000 +0200 @@ -4,4 +4,5 @@ from __future__ import absolute_import # For backward compatibility +__all__ = ['check', 'checkPath', 'checkRecursive', 'iterSourceCode', 'main'] from pyflakes.api import check, checkPath, checkRecursive, iterSourceCode, main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/test/test_api.py new/pyflakes-0.9.2/pyflakes/test/test_api.py --- old/pyflakes-0.8.1/pyflakes/test/test_api.py 2014-03-29 12:11:03.000000000 +0100 +++ new/pyflakes-0.9.2/pyflakes/test/test_api.py 2015-04-17 13:41:05.000000000 +0200 @@ -449,6 +449,13 @@ sourcePath = self.makeTempFile(source) self.assertHasErrors(sourcePath, []) + def test_CRLFLineEndings(self): + """ + Source files with Windows CR LF line endings are parsed successfully. + """ + sourcePath = self.makeTempFile("x = 42\r\n") + self.assertHasErrors(sourcePath, []) + def test_misencodedFileUTF8(self): """ If a source file contains bytes which cannot be decoded, this is diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/test/test_doctests.py new/pyflakes-0.9.2/pyflakes/test/test_doctests.py --- old/pyflakes-0.8.1/pyflakes/test/test_doctests.py 2014-03-30 03:32:53.000000000 +0200 +++ new/pyflakes-0.9.2/pyflakes/test/test_doctests.py 2015-04-17 13:41:05.000000000 +0200 @@ -64,7 +64,7 @@ """ foo - ''', m.Redefined) + ''', m.RedefinedWhileUnused) def test_importInDoctestAndAfter(self): self.flakes(''' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/test/test_imports.py new/pyflakes-0.9.2/pyflakes/test/test_imports.py --- old/pyflakes-0.8.1/pyflakes/test/test_imports.py 2014-03-30 04:47:13.000000000 +0200 +++ new/pyflakes-0.9.2/pyflakes/test/test_imports.py 2015-05-31 16:15:41.000000000 +0200 @@ -184,8 +184,9 @@ def baz(): def fu(): pass - ''', m.RedefinedWhileUnused, m.RedefinedWhileUnused, - m.UnusedImport, m.UnusedImport) + ''', + m.RedefinedWhileUnused, m.RedefinedWhileUnused, + m.UnusedImport, m.UnusedImport) def test_redefinedButUsedLater(self): """ @@ -472,6 +473,8 @@ self.flakes('import fu; [fu for _ in range(1)]') self.flakes('import fu; [1 for _ in range(1) if fu]') + @skipIf(version_info >= (3,), + 'in Python 3 list comprehensions execute in a separate scope') def test_redefinedByListComp(self): self.flakes('import fu; [1 for fu in range(1)]', m.RedefinedInListComp) @@ -502,11 +505,26 @@ ''') def test_usedInGlobal(self): + """ + A 'global' statement shadowing an unused import should not prevent it + from being reported. + """ self.flakes(''' import fu def f(): global fu ''', m.UnusedImport) + def test_usedAndGlobal(self): + """ + A 'global' statement shadowing a used import should not cause it to be + reported as unused. + """ + self.flakes(''' + import foo + def f(): global foo + def g(): foo.is_used() + ''') + @skipIf(version_info >= (3,), 'deprecated syntax') def test_usedInBackquote(self): self.flakes('import fu; `fu`') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/test/test_other.py new/pyflakes-0.9.2/pyflakes/test/test_other.py --- old/pyflakes-0.8.1/pyflakes/test/test_other.py 2014-03-30 04:07:29.000000000 +0200 +++ new/pyflakes-0.9.2/pyflakes/test/test_other.py 2015-06-17 12:15:46.000000000 +0200 @@ -21,6 +21,8 @@ f() ''', m.UndefinedLocal, m.UnusedVariable) + @skipIf(version_info >= (3,), + 'in Python 3 list comprehensions execute in a separate scope') def test_redefinedInListComp(self): """ Test that shadowing a variable in a list comprehension raises @@ -220,6 +222,8 @@ [a for a in '12'] ''') + @skipIf(version_info >= (3,), + 'in Python 3 list comprehensions execute in a separate scope') def test_redefinedElseInListComp(self): """ Test that shadowing a variable in a list comprehension in @@ -340,6 +344,15 @@ pass ''', m.RedefinedWhileUnused) + def test_classWithReturn(self): + """ + If a return is used inside a class, a warning is emitted. + """ + self.flakes(''' + class Foo(object): + return + ''', m.ReturnOutsideFunction) + @skip("todo: Too hard to make this warn but other cases stay silent") def test_doubleAssignment(self): """ @@ -463,6 +476,15 @@ foo.bar += foo.baz ''') + def test_globalDeclaredInDifferentScope(self): + """ + A 'global' can be declared in one scope and reused in another. + """ + self.flakes(''' + def f(): global foo + def g(): foo = 'anything'; foo.is_used() + ''') + class TestUnusedAssignment(TestCase): """ @@ -938,3 +960,7 @@ def bar(): yield from foo() ''', m.UndefinedName) + + def test_returnOnly(self): + """Do not crash on lone "return".""" + self.flakes('return 2') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes/test/test_undefined_names.py new/pyflakes-0.9.2/pyflakes/test/test_undefined_names.py --- old/pyflakes-0.8.1/pyflakes/test/test_undefined_names.py 2014-03-30 18:59:23.000000000 +0200 +++ new/pyflakes-0.9.2/pyflakes/test/test_undefined_names.py 2015-05-31 16:15:41.000000000 +0200 @@ -3,7 +3,7 @@ from sys import version_info from pyflakes import messages as m, checker -from pyflakes.test.harness import TestCase, skip, skipIf +from pyflakes.test.harness import TestCase, skipIf class Test(TestCase): @@ -13,6 +13,15 @@ def test_definedInListComp(self): self.flakes('[a for a in range(10) if a]') + @skipIf(version_info < (3,), + 'in Python 2 list comprehensions execute in the same scope') + def test_undefinedInListComp(self): + self.flakes(''' + [a for a in range(10)] + a + ''', + m.UndefinedName) + def test_functionsNeedGlobalScope(self): self.flakes(''' class a: @@ -83,7 +92,6 @@ bar; baz ''') - @skip("todo") def test_definedByGlobal(self): """ "global" can make an otherwise undefined name in another function @@ -93,6 +101,19 @@ def a(): global fu; fu = 1 def b(): fu ''') + self.flakes(''' + def c(): bar + def b(): global bar; bar = 1 + ''') + + def test_definedByGlobalMultipleNames(self): + """ + "global" can accept multiple names. + """ + self.flakes(''' + def a(): global fu, bar; fu = 1; bar = 2 + def b(): fu; bar + ''') def test_globalInGlobalScope(self): """ @@ -122,6 +143,74 @@ """Del an undefined name.""" self.flakes('del a', m.UndefinedName) + def test_delConditional(self): + """ + Ignores conditional bindings deletion. + """ + self.flakes(''' + context = None + test = True + if False: + del(test) + assert(test) + ''') + + def test_delConditionalNested(self): + """ + Ignored conditional bindings deletion even if they are nested in other + blocks. + """ + self.flakes(''' + context = None + test = True + if False: + with context(): + del(test) + assert(test) + ''') + + def test_delWhile(self): + """ + Ignore bindings deletion if called inside the body of a while + statement. + """ + self.flakes(''' + def test(): + foo = 'bar' + while False: + del foo + assert(foo) + ''') + + def test_delWhileTestUsage(self): + """ + Ignore bindings deletion if called inside the body of a while + statement and name is used inside while's test part. + """ + self.flakes(''' + def _worker(): + o = True + while o is not True: + del o + o = False + ''') + + def test_delWhileNested(self): + """ + Ignore bindings deletions if node is part of while's test, even when + del is in a nested block. + """ + self.flakes(''' + context = None + def _worker(): + o = True + while o is not True: + while True: + with context(): + del o + o = False + ''') + def test_globalFromNestedScope(self): """Global names are available from nested scopes.""" self.flakes(''' @@ -435,6 +524,44 @@ (42 for i in range(i)) ''', m.UndefinedName) + @skipIf(version_info < (2, 7), 'Dictionary comprehensions do not exist') + def test_definedFromLambdaInDictionaryComprehension(self): + """ + Defined name referenced from a lambda function within a dict/set + comprehension. + """ + self.flakes(''' + {lambda: id(x) for x in range(10)} + ''') + + def test_definedFromLambdaInGenerator(self): + """ + Defined name referenced from a lambda function within a generator + expression. + """ + self.flakes(''' + any(lambda: id(x) for x in range(10)) + ''') + + @skipIf(version_info < (2, 7), 'Dictionary comprehensions do not exist') + def test_undefinedFromLambdaInDictionaryComprehension(self): + """ + Undefined name referenced from a lambda function within a dict/set + comprehension. + """ + self.flakes(''' + {lambda: id(y) for x in range(10)} + ''', m.UndefinedName) + + def test_undefinedFromLambdaInComprehension(self): + """ + Undefined name referenced from a lambda function within a generator + expression. + """ + self.flakes(''' + any(lambda: id(y) for x in range(10)) + ''', m.UndefinedName) + class NameTests(TestCase): """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/pyflakes.egg-info/PKG-INFO new/pyflakes-0.9.2/pyflakes.egg-info/PKG-INFO --- old/pyflakes-0.8.1/pyflakes.egg-info/PKG-INFO 2014-03-30 20:53:07.000000000 +0200 +++ new/pyflakes-0.9.2/pyflakes.egg-info/PKG-INFO 2015-06-17 12:22:13.000000000 +0200 @@ -1,10 +1,10 @@ Metadata-Version: 1.1 Name: pyflakes -Version: 0.8.1 +Version: 0.9.2 Summary: passive checker of Python programs -Home-page: https://launchpad.net/pyflakes -Author: Florent Xicluna -Author-email: pyflakes-dev@lists.launchpad.net +Home-page: https://github.com/pyflakes/pyflakes +Author: A lot of people +Author-email: code-quality@python.org License: MIT Description: ======== Pyflakes @@ -16,10 +16,11 @@ parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster. - It is `available on PyPI http://pypi.python.org/pypi/pyflakes`_ + It is `available on PyPI https://pypi.python.org/pypi/pyflakes`_ and it supports all active versions of Python from 2.5 to 3.4. + Installation ------------ @@ -28,11 +29,42 @@ $ pip install --upgrade pyflakes + Useful tips: + + * Be sure to install it for a version of Python which is compatible + with your codebase: for Python 2, ``pip2 install pyflakes`` and for + Python3, ``pip3 install pyflakes``. + + * You can also invoke Pyflakes with ``python3 -m pyflakes .`` or + ``python2 -m pyflakes .`` if you have it installed for both versions. + + * If you require more options and more flexibility, you could give a + look to Flake8_ too. + + + Design Principles + ----------------- + Pyflakes makes a simple promise: it will never complain about style, + and it will try very, very hard to never emit false positives. + + Pyflakes is also faster than Pylint_ + or Pychecker_. This is + largely because Pyflakes only examines the syntax tree of each file + individually. As a consequence, Pyflakes is more limited in the + types of things it can check. + + If you like Pyflakes but also want styleistic checks, you want + flake8_, which combines + Pyflakes with style checks against + `PEP 8`_ and adds + per-project configuration ability. + + Mailing-list ------------ Share your feedback and ideas: `subscribe to the mailing-list - http://mail.python.org/mailman/listinfo/code-quality`_ + https://mail.python.org/mailman/listinfo/code-quality`_ .. image:: https://api.travis-ci.org/pyflakes/pyflakes.png @@ -43,6 +75,11 @@ :target: https://pypi.python.org/pypi/pyflakes :alt: Wheel Status + .. _Pylint: http://www.pylint.org/ + .. _flake8: https://pypi.python.org/pypi/flake8 + .. _`PEP 8`: http://legacy.python.org/dev/peps/pep-0008/ + .. _Pychecker: http://pychecker.sourceforge.net/ + Platform: UNKNOWN Classifier: Development Status :: 6 - Mature Classifier: Environment :: Console diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyflakes-0.8.1/setup.py new/pyflakes-0.9.2/setup.py --- old/pyflakes-0.8.1/setup.py 2014-03-29 14:32:55.000000000 +0100 +++ new/pyflakes-0.9.2/setup.py 2015-04-17 14:48:24.000000000 +0200 @@ -40,11 +40,9 @@ version=get_version(), description="passive checker of Python programs", long_description=get_long_description(), - author="Phil Frost", - author_email="indigo@bitglue.com", - maintainer="Florent Xicluna", - maintainer_email="pyflakes-dev@lists.launchpad.net", - url="https://launchpad.net/pyflakes", + author="A lot of people", + author_email="code-quality@python.org", + url="https://github.com/pyflakes/pyflakes", packages=["pyflakes", "pyflakes.scripts", "pyflakes.test"], classifiers=[ "Development Status :: 6 - Mature",
participants (1)
-
root@hilbert.suse.de