Skip to content

Instantly share code, notes, and snippets.

@myint
Last active May 24, 2017 02:41
Show Gist options
  • Save myint/df7b7f6a537a19b5a813a6d8b3cec52c to your computer and use it in GitHub Desktop.
Save myint/df7b7f6a537a19b5a813a6d8b3cec52c to your computer and use it in GitHub Desktop.
Issues in Pyflakes Launchpad
[
{
"status": "Fix Released",
"security_related": false,
"description": "Running pyflakes on this file https://github.com/conda/conda/blob/10ac568e39086df377c5f6e7fe4ecc41fda8015f/conda/logic.py I get\n\nTraceback (most recent call last):\n File \"bin/pyflakes\", line 3, in <module>\n main()\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/api.py\", line 172, in main\n warnings = checkRecursive(args, reporter)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/api.py\", line 129, in checkRecursive\n warnings += checkPath(sourcePath, reporter)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/api.py\", line 96, in checkPath\n return check(codestr, filename, reporter)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/api.py\", line 57, in check\n w = checker.Checker(tree, filename)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py\", line 295, in __init__\n self.runDeferred(self._deferredFunctions)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py\", line 332, in runDeferred\n handler()\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py\", line 818, in runFunction\n self.handleNode(stmt, node)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py\", line 607, in handleNode\n handler(node)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py\", line 565, in handleChildren\n self.handleNode(node, tree)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py\", line 607, in handleNode\n handler(node)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py\", line 729, in NAME\n self.handleNodeStore(node)\n File \"/Users/aaronmeurer/Documents/pyflakes/pyflakes/checker.py\", line 514, in handleNodeStore\n if used and used[0] is self.scope and name not in self.scope.globals:\nTypeError: 'bool' object is not subscriptable",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "asmeurer",
"id": 1465824,
"duplicate_of": null,
"title": "'bool' object is not subscriptable",
"comments": [
{
"owner": "asmeurer",
"content": "The change from 531b6b58 (shown below) seems to be related, but even after reverting it it gives the same error. \n\n@@ -473,8 +477,8 @@ class Checker(object):\n # if the name was defined in that scope, and the name has\n # been accessed already in the current scope, and hasn't\n # been declared global\n- if (name in scope and scope[name].used and scope[name].used[0] is self.scope\n- and name not in self.scope.globals):\n+ used = name in scope and scope[name].used\n+ if used and used[0] is self.scope and name not in self.scope.globals:\n # then it's probably a mistake\n self.report(messages.UndefinedLocal,\n scope[name].used[1], name, scope[name].source)",
"date_created": "2015-06-16T19:46:23Z"
},
{
"owner": "asmeurer",
"content": "I think the problem is https://github.com/pyflakes/pyflakes/pull/19/files#diff-f0429ba5bb9de6e83abcf687aca4c012R702. That change from the older commit still looks wrong, though (used will always be a boolean). ",
"date_created": "2015-06-16T19:48:17Z"
},
{
"owner": "asmeurer",
"content": "Oh derp, 'and' returns the object, not a boolean. Still, it's a bit confusing. \n\nThe bug itself is fixed by https://github.com/pyflakes/pyflakes/pull/22. ",
"date_created": "2015-06-17T01:27:30Z"
},
{
"owner": "bitglue",
"content": "Released 0.9.2.",
"date_created": "2015-06-17T10:24:23Z"
}
],
"importance": "Critical",
"lp_url": "https://bugs.launchpad.net/bugs/1465824",
"date_created": "2015-06-16T19:41:07Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "This simple code make pyflakes throw and exception (python 2.7.11 and 3.5.1).\n-------------------------------------------\n# -*- coding: utf-8 -*-\n\nfrom . import foo\n\nclass MyClass(object):\n pass\n-------------------------------------------\nTraceback (most recent call last):\n File \"/usr/lib/python3.5/runpy.py\", line 170, in _run_module_as_main\n \"__main__\", mod_spec)\n File \"/usr/lib/python3.5/runpy.py\", line 85, in _run_code\n exec(code, run_globals)\n File \"pyflakes/__main__.py\", line 5, in <module>\n main(prog='pyflakes')\n File \"/home/mal/develop/python/pyflakes/pyflakes/api.py\", line 184, in main\n warnings = checkRecursive(args, reporter)\n File \"/home/mal/develop/python/pyflakes/pyflakes/api.py\", line 141, in checkRecursive\n warnings += checkPath(sourcePath, reporter)\n File \"/home/mal/develop/python/pyflakes/pyflakes/api.py\", line 108, in checkPath\n return check(codestr, filename, reporter)\n File \"/home/mal/develop/python/pyflakes/pyflakes/api.py\", line 69, in check\n w = checker.Checker(tree, filename)\n File \"/home/mal/develop/python/pyflakes/pyflakes/checker.py\", line 403, in __init__\n self.handleChildren(tree)\n File \"/home/mal/develop/python/pyflakes/pyflakes/checker.py\", line 725, in handleChildren\n self.handleNode(node, tree)\n File \"/home/mal/develop/python/pyflakes/pyflakes/checker.py\", line 772, in handleNode\n handler(node)\n File \"/home/mal/develop/python/pyflakes/pyflakes/checker.py\", line 1151, in IMPORTFROM\n node.module, alias.name)\n File \"/home/mal/develop/python/pyflakes/pyflakes/checker.py\", line 199, in __init__\n full_name = module + '.' + self.real_name\nTypeError: unsupported operand type(s) for +: 'NoneType' and 'str'",
"tags": [],
"duplicates": [
1580214
],
"assignee": "jayvdb",
"milestone": null,
"owner": "ma-latorre-diaz",
"id": 1560134,
"duplicate_of": null,
"title": "TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'",
"comments": [
{
"owner": "bitglue",
"content": "I'm pretty sure this is fixed in the current version of pyflakes. What version are you using?",
"date_created": "2016-03-21T20:22:26Z"
},
{
"owner": "ma-latorre-diaz",
"content": "Version: 1.1.0\nLatest commit: aec68a7847d8dbd1371242f42f9302103a68178f\n\ncommit aec68a7847d8dbd1371242f42f9302103a68178f\nAuthor: John Vandenberg <email address hidden>\nDate: Thu Nov 26 01:24:53 2015 +1100\n\n Importation classes with imported name and alias\n\n In order to solve many corner cases related to imports,\n more information is needed about each import.\n\n This change creates two new classes:\n - SubmoduleImportation\n - ImportationFrom\n\n And adds an optional parameter full_name to the super class\n Importation.\n\n Functionally, this change only improves existing error messages\n to report the full imported name where previously an error\n would include only the import alias.\n\n",
"date_created": "2016-03-21T20:37:21Z"
},
{
"owner": "ma-latorre-diaz",
"content": "I'm a mercurial user so, just in case:\n> git status\nOn branch master\nYour branch is up-to-date with 'origin/master'.\nnothing to commit, working directory clean\n",
"date_created": "2016-03-21T20:47:48Z"
},
{
"owner": "bitglue",
"content": "Hm...1.1.0 is pretty recent. I'll have to investigate this more when I have some time. Thanks for the report.",
"date_created": "2016-03-21T21:45:49Z"
},
{
"owner": "predder",
"content": "This happens for me in 1.2 but not 1.0 or 1.1.\n\nnathan@w530 ~/code/inbox-persist \u266a flake8 inboxpersist/\nTraceback (most recent call last):\n File \"/usr/local/bin/flake8\", line 11, in <module>\n sys.exit(main())\n File \"/usr/local/lib/python2.7/dist-packages/flake8/main.py\", line 33, in main\n report = flake8_style.check_files()\n File \"/usr/local/lib/python2.7/dist-packages/flake8/engine.py\", line 180, in check_files\n return self._retry_serial(self._styleguide.check_files, paths=paths)\n File \"/usr/local/lib/python2.7/dist-packages/flake8/engine.py\", line 171, in _retry_serial\n return func(*args, **kwargs)\n File \"/usr/local/lib/python2.7/dist-packages/pep8.py\", line 1840, in check_files\n self.input_dir(path)\n File \"/usr/local/lib/python2.7/dist-packages/pep8.py\", line 1876, in input_dir\n runner(os.path.join(root, filename))\n File \"/usr/local/lib/python2.7/dist-packages/flake8/engine.py\", line 125, in input_file\n return fchecker.check_all(expected=expected, line_offset=line_offset)\n File \"/usr/local/lib/python2.7/dist-packages/pep8.py\", line 1574, in check_all\n self.check_ast()\n File \"/usr/local/lib/python2.7/dist-packages/pep8.py\", line 1520, in check_ast\n checker = cls(tree, self.filename)\n File \"/usr/local/lib/python2.7/dist-packages/flake8/_pyflakes.py\", line 43, in __init__\n withDoctest=self.withDoctest)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/checker.py\", line 402, in __init__\n self.handleChildren(tree)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/checker.py\", line 724, in handleChildren\n self.handleNode(node, tree)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/checker.py\", line 771, in handleNode\n handler(node)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/checker.py\", line 1150, in IMPORTFROM\n node.module, alias.name)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/checker.py\", line 198, in __init__\n full_name = module + '.' + self.real_name\nTypeError: unsupported operand type(s) for +: 'NoneType' and 'str'\n",
"date_created": "2016-05-04T07:29:41Z"
},
{
"owner": "jayvdb",
"content": "fwiw, there is a version mixup at the moment, with pypi providing 1.2.0 but master is still 1.1.0\n(https://github.com/pyflakes/pyflakes/blob/master/pyflakes/__init__.py)\n\nThanks for the report Miguel. I can see where the problem is, and should have a fix shortly.\n",
"date_created": "2016-05-04T07:55:39Z"
},
{
"owner": "bitglue",
"content": "I just updated master. Forgot to push last night when I made the release :)",
"date_created": "2016-05-04T11:26:13Z"
},
{
"owner": "jayvdb",
"content": "fwiw, I have a fix https://github.com/jayvdb/pyflakes/commit/5c039f90b78fb4eb2b10287295f411e86baa8233\n\nBut I am working on another approach, as relative imports can also be star imports, and it would be nice to fix the error messages for star import at the same time. Should only be an hour or so.",
"date_created": "2016-05-04T11:44:44Z"
},
{
"owner": "jayvdb",
"content": "https://github.com/pyflakes/pyflakes/pull/61",
"date_created": "2016-05-04T12:31:58Z"
},
{
"owner": "patrick-m-dunnigan",
"content": "This is still a problem in 1.2.2. Cannot run pyflakes whatsoever. ",
"date_created": "2016-05-06T16:57:49Z"
},
{
"owner": "bitglue",
"content": "If you'd like to see a fix faster, feel free to review https://github.com/pyflakes/pyflakes/pull/61\n",
"date_created": "2016-05-06T17:14:23Z"
},
{
"owner": "smoser",
"content": "Just ran into this in Ubuntu Yakkety which and filed bug 1580214. Then duped that here.\nRecreate is as simple as:\n\n$ mkdir x\n$ echo \"FOO = 1\" > x/__init__.py\n$ echo \"from . import FOO\" > x/wark.py\n$ python -m pyflakes x/\n",
"date_created": "2016-05-10T14:58:41Z"
},
{
"owner": "barry",
"content": "This currently only affects Yakkety (or a PyPI or from-source install). Xenial isn't affected. I've subscribed to the upstream bug and will cherry pick it once they land the fix, or upload a new upstream if that's provided soon after.",
"date_created": "2016-05-10T18:18:29Z"
},
{
"owner": "ma-latorre-diaz",
"content": "My current workaround is changing checker.py:212 from:\n\nfull_name = module + '.' + self.real_name\n\nto\n\nfull_name = (module or '') + '.' + self.real_name\n",
"date_created": "2016-05-10T19:58:44Z"
},
{
"owner": "smoser",
"content": "well, heres to hoping there is something for barry to cherry pick soon.\nCurrently anything that uses this in its build is probably FTBFS (fails to build from source). Example is curtin. I'm forced to skip or wait to upload.\n\nI'm sure that curtin isn't the only thing that does this.\n",
"date_created": "2016-05-10T20:59:12Z"
},
{
"owner": "barry",
"content": "@ma-latorre-diaz: That fixes it for me too. I've added a DEP-8 test for this case, and a quilt patch as you suggest. I see no other regressions, so I'll upload this fix to Debian and it should autosync to Yakkety soon enough. We can remove the patch when a new upstream with the fix is available. Thanks!",
"date_created": "2016-05-11T21:29:22Z"
},
{
"owner": "jayvdb",
"content": "With that one-line fix, the error message reported will be wrong. The correct fix is in the github PR.",
"date_created": "2016-05-12T00:50:54Z"
},
{
"owner": "barry",
"content": "On May 12, 2016, at 12:50 AM, John Vandenberg wrote:\n\n>With that one-line fix, the error message reported will be wrong. The\n>correct fix is in the github PR.\n\nI'm subscribed to the PR and will update the patch once that gets accepted and\nmerged. It looks like there's still some discussion going on about it?\n\nFor now, it's good just that pyflakes doesn't crash.\n",
"date_created": "2016-05-12T13:16:45Z"
},
{
"owner": "jayvdb",
"content": "The current patch addresses all previous review comments by reviewers.",
"date_created": "2016-05-12T15:29:13Z"
},
{
"owner": "barry",
"content": "On May 12, 2016, at 03:29 PM, John Vandenberg wrote:\n\n>The current patch addresses all previous review comments by reviewers.\n\nI'll try it out instead of the current quick hack. Once a new upstream is\nreleased with the fix, I'll upload it dropping the patch.\n",
"date_created": "2016-05-12T16:50:59Z"
}
],
"importance": "Critical",
"lp_url": "https://bugs.launchpad.net/bugs/1560134",
"date_created": "2016-03-21T17:12:45Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "The following code causes an exception\n\ntry:\n pass\nexcept Exception as e:\n del e\n\n$ python3.4 -m pyflakes test_del_exception.py\nTraceback (most recent call last):\n File \"/usr/lib64/python3.4/runpy.py\", line 170, in _run_module_as_main\n \"__main__\", mod_spec)\n File \"/usr/lib64/python3.4/runpy.py\", line 85, in _run_code\n exec(code, run_globals)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/__main__.py\", line 5, in <module>\n main(prog='pyflakes')\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/api.py\", line 184, in main\n warnings = checkRecursive(args, reporter)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/api.py\", line 141, in checkRecursive\n warnings += checkPath(sourcePath, reporter)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/api.py\", line 108, in checkPath\n return check(codestr, filename, reporter)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/api.py\", line 69, in check\n w = checker.Checker(tree, filename)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py\", line 425, in __init__\n self.handleChildren(tree)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py\", line 747, in handleChildren\n self.handleNode(node, tree)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py\", line 794, in handleNode\n handler(node)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py\", line 1196, in TRY\n self.handleChildren(node, omit='body')\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py\", line 747, in handleChildren\n self.handleNode(node, tree)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py\", line 794, in handleNode\n handler(node)\n File \"/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py\", line 1226, in EXCEPTHANDLER\n del self.scope[node.name]\nKeyError: 'e'\n\nThis was introduced in 1.2.0 with https://github.com/pyflakes/pyflakes/commit/2a698f87c02a43d4489e30481e9def14ed4b4431",
"tags": [],
"duplicates": [],
"assignee": "bitglue",
"milestone": null,
"owner": "jayvdb",
"id": 1578903,
"duplicate_of": null,
"title": "del of exception causes Exception",
"comments": [
{
"owner": "bitglue",
"content": "Looks like this happens with Python 3 only.",
"date_created": "2016-05-06T10:45:50Z"
},
{
"owner": "bitglue",
"content": "https://github.com/pyflakes/pyflakes/pull/67",
"date_created": "2016-05-06T10:53:39Z"
},
{
"owner": "jayvdb",
"content": "Yes, the new exception processing which causes this is Python 3 only",
"date_created": "2016-05-06T11:22:32Z"
}
],
"importance": "Critical",
"lp_url": "https://bugs.launchpad.net/bugs/1578903",
"date_created": "2016-05-06T03:37:03Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Pyflakes complains that 'a' is unused, and doesn't spot that 'b' and 'c' are undefined, in the following code:\n\ndef f(seq):\n a = 0\n seq[a] += 1\n seq[b] /= 2\n c[0] *= 2\n\nIt seems to work correctly with assignments to slices, and in-place operations that don't involve slices.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.6.1",
"owner": "bistromathic1-5",
"id": 1108904,
"duplicate_of": null,
"title": "Variables on LHS of in-place slice operations are ignored",
"comments": [
{
"owner": "florent.x",
"content": "This is confirmed as a regression of pyflakes 0.6.",
"date_created": "2013-01-29T15:00:19Z"
},
{
"owner": "florent.x",
"content": "Thank you, fixed in 0.6.1.",
"date_created": "2013-01-29T15:41:17Z"
}
],
"importance": "High",
"lp_url": "https://bugs.launchpad.net/bugs/1108904",
"date_created": "2013-01-29T13:58:05Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "The calculation of the line number is wrong for Doctest syntax error.\n\nhttps://bitbucket.org/tarek/flake8/issue/105/indexerror-on-pep8\n\nThis is a regression of Pyflakes 0.7 and 0.7.1",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7.2",
"owner": "florent.x",
"id": 1172130,
"duplicate_of": null,
"title": "Wrong line number for Doctext syntax error",
"comments": [],
"importance": "High",
"lp_url": "https://bugs.launchpad.net/bugs/1172130",
"date_created": "2013-04-24T05:57:21Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "As of python 3.4.0 pyflakes will crash in checker.py: \n\nFile \"../site-packages/pyflakes/checker.py\", line 730, in LAMBDA\n for annotation in (node.args.varargannotation,\nAttributeError: 'arguments' object has no attribute 'varargannotation'\n\nCode that generates the error\n\n if hasattr(node, 'returns'): # Only for FunctionDefs \n for annotation in (node.args.varargannotation,\n node.args.kwargannotation, node.returns):\n\t self.handleNode(annotation, node)\n\n\nIt seems that the module ast has changed from python 3.3 to 3.4. The attribute 'varargannotation' is no longer present in the newer version.\n\nIn 3.3 the documentation: (http://docs.python.org/3.3/library/ast.html#abstract-grammar)\n \narguments = (arg* args, identifier? vararg, expr? varargannotation,\n arg* kwonlyargs, identifier? kwarg,\n expr? kwargannotation, expr* defaults,\n expr* kw_defaults)\n\nIn 3.4 the dokumentation says: (http://docs.python.org/3.4/library/ast.html#abstract-grammar)\n\narguments = (arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults,\n arg? kwarg, expr* defaults)",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8",
"owner": "moln",
"id": 1295554,
"duplicate_of": null,
"title": "pyflakes crashes with AttributeError. No attribute 'varargannotation'",
"comments": [
{
"owner": "moln",
"content": "Circumventing the reported error reveals a second bug:\n\nAttributeError: 'FlakesChecker' object has no attribute 'NAMECONSTANT'. I assume this has to do with the new Enumeration type in 3.4. Anyhow a second fix avoids also this crash to get it back to a \"working\" state.\n\nThese fixes should just be considered a hint at how to fix these problems.\n\n\n\n\n\n",
"date_created": "2014-03-21T09:20:08Z"
},
{
"owner": "florent.x",
"content": "Alreasy fixed in trunk.",
"date_created": "2014-03-22T14:07:36Z"
},
{
"owner": "sorin-sbarnea",
"content": "This tells me that people are probably not using not using pyflakes with python 3.5 or 3.4",
"date_created": "2016-03-01T11:04:04Z"
},
{
"owner": "sorin-sbarnea",
"content": "Here is another one that seems very similar to me:\n\n File \"/Users/sorins/bmll/flare/env/lib/python3.5/site-packages/pyflakes/checker.py\", line 462, in getNodeHandler\n self._nodeHandlers[node_class] = handler = getattr(self, nodeType)\nAttributeError: 'FlakesChecker' object has no attribute 'MATMULT'\n",
"date_created": "2016-03-01T11:05:29Z"
}
],
"importance": "High",
"lp_url": "https://bugs.launchpad.net/bugs/1295554",
"date_created": "2014-03-21T08:28:10Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "There are numerous bug fixes included in pyflakes since 0.8.1 was released (over a year ago). A new release would be greatly appreciated.",
"tags": [],
"duplicates": [
1459239
],
"assignee": "bitglue",
"milestone": null,
"owner": "icordasc",
"id": 1459240,
"duplicate_of": null,
"title": "Release 0.8.2 or 0.9.0",
"comments": [
{
"owner": "bitglue",
"content": "Acknowledged. I should have access to the PyPI listing now so I'll give this a shot soon.",
"date_created": "2015-05-27T14:49:36Z"
},
{
"owner": "frewsxcv",
"content": "0.9.0 has been released, so this can be closed, right?",
"date_created": "2015-06-02T19:07:13Z"
},
{
"owner": "bitglue",
"content": "Yuppers!",
"date_created": "2015-06-02T20:04:37Z"
}
],
"importance": "High",
"lp_url": "https://bugs.launchpad.net/bugs/1459240",
"date_created": "2015-05-27T13:28:52Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "The following code:\n\nclass Foo(object):\n from bar import baz\n def __init__(self):\n self.foo = self.baz()\n\ndetects 'baz' as \"imported but unused\".\n\n____\nPlease open github for issues!",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "spaceone",
"id": 1463566,
"duplicate_of": null,
"title": "false positive: imported but unused",
"comments": [
{
"owner": "jayvdb",
"content": "https://github.com/pyflakes/pyflakes/pull/44 proposes a fix for this.",
"date_created": "2015-11-15T09:56:34Z"
}
],
"importance": "High",
"lp_url": "https://bugs.launchpad.net/bugs/1463566",
"date_created": "2015-06-09T20:59:13Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "The latest published pyflakes version doesn't process brand new async def constructions from pep 492.\nBut I see https://github.com/pyflakes/pyflakes/pull/30 with fix is merged to master.\n\nPlease make a PyPI release with the fix -- Python 3.5 has been release last week.",
"tags": [],
"duplicates": [],
"assignee": "bitglue",
"milestone": null,
"owner": "andrew-svetlov",
"id": 1497690,
"duplicate_of": null,
"title": "Create new PyPI release",
"comments": [
{
"owner": "bitglue",
"content": "done!",
"date_created": "2015-09-20T16:01:00Z"
},
{
"owner": "andrew-svetlov",
"content": "Thanks!",
"date_created": "2015-09-20T17:51:23Z"
}
],
"importance": "High",
"lp_url": "https://bugs.launchpad.net/bugs/1497690",
"date_created": "2015-09-20T07:28:05Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Let's say you have this file:\n\n#! /usr/bin/python\nfrom __future__ import print_function\nimport sys\nprint('test', file=sys.stderr)\n\nthen pyflakes correct recognizes the print function and is happy. However, let's say you change the first line to\n\n#!/usr/bin/python3\n\nand remove the future import. Then pyflakes isn't so happy about the print() function.\n\nNo doubt it's a considerable amount of work to support Python 3 directly, but at least with this bug we can track that effort.",
"tags": [],
"duplicates": [
1085352
],
"assignee": "florent.x",
"milestone": "0.6.1",
"owner": "barry",
"id": 989203,
"duplicate_of": null,
"title": "pyflakes native support for Python 3",
"comments": [
{
"owner": "florent.x",
"content": "This branch brings Python 3 support https://github.com/florentx/pyflakes\n\nIt is based on version 0.5 from lp:divmod.org",
"date_created": "2012-12-29T22:25:33Z"
},
{
"owner": "florent.x",
"content": "Planned after the switch to unittest2 for the tests (https://bugs.launchpad.net/pyflakes/+bug/1097061).\n\nThe only limitation will be that you need to run with Python2 to check Python2 code, and you'll need to run with Python3 to check Python3 code.",
"date_created": "2013-01-08T01:30:10Z"
},
{
"owner": "bistromathic1",
"content": "Maybe you are aware of this (and thanks for adding python 3 support!), but there are some bits of new syntax that don't seem to be covered by this fix. The following code causes pyflakes to complain that ABCMeta is unused:\n\nfrom abc import ABCMeta\n\n\nclass A(metaclass=ABCMeta): # new metaclass syntax\n pass\n\n\ndef f(a: ABCMeta): # annotations\n pass\n\n\ndef g(a, *args, b=ABCMeta): # defaults for keyword-only arguments\n pass",
"date_created": "2013-01-28T14:32:50Z"
},
{
"owner": "florent.x",
"content": "Thank you for reporting it\r\n\r\nI will investigate these cases.",
"date_created": "2013-01-28T15:37:26Z"
},
{
"owner": "florent.x",
"content": "Should be fixed with latest change (rev 61).\r\n\r\nhttps://github.com/pyflakes/pyflakes/commit/02864b26e590893f7effd61d96460e60ff6dec7f\r\n\r\nThank you",
"date_created": "2013-01-28T17:58:10Z"
},
{
"owner": "florent.x",
"content": "Change landed in trunk: http://bazaar.launchpad.net/~pyflakes-dev/pyflakes/master/revision/61",
"date_created": "2013-01-28T17:59:38Z"
}
],
"importance": "Medium",
"lp_url": "https://bugs.launchpad.net/bugs/989203",
"date_created": "2012-04-26T20:25:49Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Hello,\n\nFollowing the discussion on the mailing-list, I propose to extract the Pyflakes repository and publish it under the Pyflakes project.\n\nThe main reason is that it is less confusing for all\nthe actors (users, developers, etc...) to find the project at a single\nplace: the source code, the issue tracker, the downloads...\nSecond reason, is that it makes it easier for external contributions. You\nonly clone the PyFlakes project, without need to download the code of all\nthe unrelated Divmod's projects. Same benefit when someone want to mirror\nthe code on any other VCS.\nAnd the PyFlakes project is so widely used, that it deserves to have its\nown repository.\n\n\nI did an export of the current state of the Pyflakes/ folder, with history.\nIt is available as lp:~divmod-dev/pyflakes/trunk\n\nIf accepted, the next moves are:\n\n* setup lp:pyflakes as the alias for lp:~divmod-dev/pyflakes/trunk\n* submit a MP to remove Pyflakes from the lp:divmod.org repository\n* update the homepage of https://launchpad.net/pyflakes to inform where is the source code\n* update the documentation at http://divmod.readthedocs.org/en/latest/products/pyflakes.html\n\nThen the open issues will be reviewed and the merge proposals will be updated to target the new repository.\n(There's only few small patches, I already had a look)",
"tags": [],
"duplicates": [],
"assignee": "florent.x",
"milestone": "0.6.1",
"owner": "florent.x",
"id": 1095248,
"duplicate_of": null,
"title": "move Pyflakes to its own repository",
"comments": [
{
"owner": "florent.x",
"content": "The repository is now linked with lp:pyflakes.\n\nThe branch for the issue 916264 is migrated too: lp:~divmod-dev/pyflakes/less-redef\nThe other branch has a single change http://bazaar.launchpad.net/~witsch/divmod.org/Pyflakes/revision/2699/Pyflakes/setup.py but it does not seem related to any existing issue.\n\n\nThe old directory can be removed from divmod.org/Pyflakes : merge proposal is attached to this issue.",
"date_created": "2013-01-07T20:59:35Z"
},
{
"owner": "florent.x",
"content": "Pyflakes is now removed from divmod.org repository.\n\nI've submitted a pull-request for the documentation:\nhttps://github.com/MostAwesomeDude/divmod-docs/pull/8\n",
"date_created": "2013-01-08T02:02:10Z"
}
],
"importance": "Medium",
"lp_url": "https://bugs.launchpad.net/bugs/1095248",
"date_created": "2013-01-07T07:06:42Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "I propose to switch to unittest2 instead of Twisted in order to test against more versions of Python (2.5 and Python 3).\n\nMoreover unittest is more focused than the Twisted framework and it is less code to download and install (for automated tests).",
"tags": [],
"duplicates": [],
"assignee": "florent.x",
"milestone": "0.6.1",
"owner": "florent.x",
"id": 1097061,
"duplicate_of": null,
"title": "switch to unittest2 for the test framework",
"comments": [
{
"owner": "florent.x",
"content": "Related to issue #989203 too.\nhttps://bugs.launchpad.net/pyflakes/+bug/989203\n",
"date_created": "2013-01-07T22:36:18Z"
}
],
"importance": "Medium",
"lp_url": "https://bugs.launchpad.net/bugs/1097061",
"date_created": "2013-01-07T22:35:52Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "When updating from pyflakes 0.5.0 to pyflakes 0.6.1 many occurances of 'list comprehension redefines' are listed erroneously. The issue appears to be that pyflakes will complain about reusing the same loop variable name in multiple list comprehensions.\n\nHere are two lines for example:\n\n168:\nwells = Well.objects.filter(id__in=(well.id for well in wells))\n \n...\n\n183:\nfx_wells = [well for well in wells if well.assay_subtype == fx_subtype]\n\nAnd a message such as below appears.\n\nfoo/bar.py:183:: list comprehension redefines 'well' from line 168\n\nIn this case pyflakes should be smart enough to realize that 'well' will not be incorrectly used because it will be initialized immediately with the expected value in the second list comprehension.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7",
"owner": "jfalkner",
"id": 1112067,
"duplicate_of": null,
"title": "Erroneous 'list comprehension redefines' in Python 2.7 pyflakes 0.6.1",
"comments": [
{
"owner": "icordasc",
"content": "I couldn't reproduce this with the attached file.",
"date_created": "2013-02-02T18:43:11Z"
},
{
"owner": "bistromathic1",
"content": "This problem seems to occur when a dummy variable name in a generator expression, a dict comprehension, or a set comprehension is then reused in a list comprehension, for example:\n\na = [1, 2, 3, 4, 5, 6]\n\nb = (i + 1 for i in a)\nc = [i + 2 for i in b]\n\nprint(c)\n\nThe pyflakes output is:\n\ntest-1.py:4: list comprehension redefines 'i' from line 3\n\nI only tried this in python 3.2.",
"date_created": "2013-02-07T23:30:47Z"
},
{
"owner": "florent.x",
"content": "actually, this should not report redefinition of variable for:\r\n * generator expressions\r\n * dict comprehensions\r\n * set comprehensions\r\n\r\nOnly the list comprehension leaks its variable, and only with Python 2.x.\r\n(Though we'll keep reporting the warning for 3.x as well)",
"date_created": "2013-02-08T00:56:00Z"
},
{
"owner": "florent.x",
"content": "This should fix it.\n\nhttps://code.launchpad.net/~pyflakes-dev/pyflakes/1112067-comprehension-scope/+merge/147264",
"date_created": "2013-02-08T01:02:46Z"
},
{
"owner": "danken",
"content": "I'm not sure it's the very same bug, but pylakes 0.6.1 (python 2.7.3) considers the following as having a redefinition of x:\n\nif False:\n x = 1\nelse:\n [x for x in [1]]\n",
"date_created": "2013-02-28T12:40:41Z"
},
{
"owner": "florent.x",
"content": "> I'm not sure it's the very same bug, but pylakes 0.6.1 (python 2.7.3) considers the following as having a redefinition of x:\n> \n> if False:\n> x = 1\n> else:\n> [x for x in [1]]\n\n\nthis last one is a different bug, it should be reported separately.",
"date_created": "2013-03-05T18:21:21Z"
},
{
"owner": "florent.x",
"content": "The fix for this second bug was added to the same branch:\nhttps://code.launchpad.net/~pyflakes-dev/pyflakes/1112067-comprehension-scope/+merge/147264\n",
"date_created": "2013-03-06T22:42:04Z"
}
],
"importance": "Medium",
"lp_url": "https://bugs.launchpad.net/bugs/1112067",
"date_created": "2013-02-01T03:19:15Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "This is with pyflakes 0.7, Python 2.7.3, LANG=en_US.UTF-8 on Fedora 17:\n\n$ pyflakes p\u00f6\u00f6\nTraceback (most recent call last):\n File \"/usr/bin/pyflakes\", line 9, in <module>\n load_entry_point('pyflakes==0.7', 'console_scripts', 'pyflakes')()\n File \"/usr/lib/python2.7/site-packages/pyflakes/api.py\", line 129, in main\n warnings = checkRecursive(args, reporter)\n File \"/usr/lib/python2.7/site-packages/pyflakes/api.py\", line 120, in checkRecursive\n warnings += checkPath(sourcePath, reporter)\n File \"/usr/lib/python2.7/site-packages/pyflakes/api.py\", line 86, in checkPath\n reporter.unexpectedError(filename, msg.args[1])\n File \"/usr/lib/python2.7/site-packages/pyflakes/reporter.py\", line 40, in unexpectedError\n self._stderr.write(u(\"%s: %s\\n\") % (filename, msg))\nUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)\n\n0.6.1 fails the same way, but 0.5 works:\n\n$ pyflakes p\u00f6\u00f6\np\u00f6\u00f6: No such file or directory",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7.1",
"owner": "vskytta",
"id": 1170459,
"duplicate_of": null,
"title": "Reporting errors in non-ASCII filenames fails",
"comments": [
{
"owner": "florent.x",
"content": "Confirmed with Python 2.x",
"date_created": "2013-04-18T21:10:10Z"
},
{
"owner": "vskytta",
"content": "Fix otherwise confirmed, but if stderr is redirected to a file it still fails:\n\n$ pyflakes p\u00f6\u00f6 2>stderr.out\n$ cat stderr.out\nTraceback (most recent call last):\n File \"/usr/bin/pyflakes\", line 9, in <module>\n load_entry_point('pyflakes==0.7.1a0', 'console_scripts', 'pyflakes')()\n File \"/usr/lib/python2.7/site-packages/pyflakes/api.py\", line 129, in main\n warnings = checkRecursive(args, reporter)\n File \"/usr/lib/python2.7/site-packages/pyflakes/api.py\", line 120, in checkRecursive\n warnings += checkPath(sourcePath, reporter)\n File \"/usr/lib/python2.7/site-packages/pyflakes/api.py\", line 86, in checkPath\n reporter.unexpectedError(filename, msg.args[1])\n File \"/usr/lib/python2.7/site-packages/pyflakes/reporter.py\", line 45, in unexpectedError\n _write(self._stderr, \"%s: %s\\n\" % (filename, msg))\n File \"/usr/lib/python2.7/site-packages/pyflakes/reporter.py\", line 11, in _write\n stream.write(text.decode(encoding, 'replace'))\nUnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2: ordinal not in range(128)\n",
"date_created": "2013-04-19T14:16:26Z"
},
{
"owner": "florent.x",
"content": "Thank you for this review.\n\nI've reworked the fix, and it seems to work better in all cases.",
"date_created": "2013-04-21T09:51:31Z"
}
],
"importance": "Medium",
"lp_url": "https://bugs.launchpad.net/bugs/1170459",
"date_created": "2013-04-18T19:14:14Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Running the pyflakes checker on a code I get this:\n\n File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/api.py\", line 88, in checkPath\n return check(codestr, filename, reporter)\n File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/api.py\", line 58, in check\n w = checker.Checker(tree, filename)\n File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py\", line 294, in __init__\n self.handleChildren(tree)\n File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py\", line 547, in handleChildren\n self.handleNode(node, tree)\n File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py\", line 589, in handleNode\n handler(node)\n File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py\", line 547, in handleChildren\n self.handleNode(node, tree)\n File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py\", line 589, in handleNode\n handler(node)\n File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyflakes-0.8.1-py2.6.egg/pyflakes/checker.py\", line 696, in RETURN\n if node.value and not self.scope.returnValue:\nAttributeError: 'ModuleScope' object has no attribute 'returnValue'\n\nUnluckily I'm not able to check the code that raise the error (it's a 3rd party legacy code full of errors).\n\nI skipped the issue changing the line 696 to:\n\n if node.value and hasattr(self.scope, 'returnValue') and not self.scope.returnValue:",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8.2",
"owner": "lucafbb",
"id": 1332451,
"duplicate_of": null,
"title": "AttributeError: 'ModuleScope' object has no attribute 'returnValue'",
"comments": [
{
"owner": "florent.x",
"content": "I can reproduce this case with the following (invalid) snippet:\r\n\r\nclass Foo(object):\r\n return\r\n\r\n\r\nAll versions of Python.",
"date_created": "2014-07-26T11:04:50Z"
},
{
"owner": "adiroiban",
"content": "I have created a pull request to work on this https://github.com/pyflakes/pyflakes/pull/13\n\nIt looks like code on master already handles this condition so I think that we should not merge pull #13 but just close this tickets as solved.\n\nThanks!",
"date_created": "2015-02-14T12:00:56Z"
},
{
"owner": "gforcada",
"content": "I hit the same error... can we get a new release please? I see that there are quite a few changes pending to be released... ",
"date_created": "2015-05-28T10:19:24Z"
}
],
"importance": "Medium",
"lp_url": "https://bugs.launchpad.net/bugs/1332451",
"date_created": "2014-06-20T08:05:44Z"
},
{
"status": "Confirmed",
"security_related": false,
"description": "$ cat tt.py\n#!/usr/bin/python -tt\nimport random\nimport sys\n\ndef main():\n\u00a0\u00a0\u00a0\u00a0f = None\n\u00a0\u00a0\u00a0\u00a0try:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0f = \"bob\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if random.choice((True, False)):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0raise Exception('test')\n\u00a0\u00a0\u00a0\u00a0except:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0del f\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0raise Exception('my custom exception')\n\u00a0\u00a0\u00a0\u00a0print f\n\nif '__main__' == __name__:\n\u00a0\u00a0\u00a0\u00a0sys.exit(main())\n\n$ $ pyflakes tt.py\ntt.py:15: undefined name 'f'",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "happycamp",
"id": 1431099,
"duplicate_of": null,
"title": "pyflakes gives erroneous 'undefined name'",
"comments": [
{
"owner": "bitglue",
"content": "Confirmed. Thanks for the report.",
"date_created": "2015-05-27T15:06:34Z"
},
{
"owner": "peuchele",
"content": "I was about to report the same issue, but with a different example. Pasting here for reference:\nx = 0\nwhile True:\n data = \"dummy\"\n if x == 1:\n del data\n break\n print data\n del data\n break\n\nReal life example:\nhttps://github.com/jelmer/dulwich/blob/master/dulwich/protocol.py#L353",
"date_created": "2015-09-29T11:47:14Z"
},
{
"owner": "jayvdb",
"content": "I believe these are both the same problem as https://bugs.launchpad.net/pyflakes/+bug/1308508 .",
"date_created": "2015-11-20T21:07:19Z"
}
],
"importance": "Medium",
"lp_url": "https://bugs.launchpad.net/bugs/1431099",
"date_created": "2015-03-12T01:02:41Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Tested with pyflakes 0.8.1. Make this file:\n\nclass A():\n def a():\n return 5\n return 7\n\nRun it with pyflakes, you get:\n\nTraceback (most recent call last):\n File \"/usr/bin/pyflakes\", line 9, in <module>\n load_entry_point('pyflakes==0.8.1', 'console_scripts', 'pyflakes')()\n File \"/usr/lib/python2.7/dist-packages/pyflakes/api.py\", line 130, in main\n warnings = checkRecursive(args, reporter)\n File \"/usr/lib/python2.7/dist-packages/pyflakes/api.py\", line 121, in checkRecursive\n warnings += checkPath(sourcePath, reporter)\n File \"/usr/lib/python2.7/dist-packages/pyflakes/api.py\", line 88, in checkPath\n return check(codestr, filename, reporter)\n File \"/usr/lib/python2.7/dist-packages/pyflakes/api.py\", line 58, in check\n w = checker.Checker(tree, filename)\n File \"/usr/lib/python2.7/dist-packages/pyflakes/checker.py\", line 294, in __init__\n self.handleChildren(tree)\n File \"/usr/lib/python2.7/dist-packages/pyflakes/checker.py\", line 547, in handleChildren\n self.handleNode(node, tree)\n File \"/usr/lib/python2.7/dist-packages/pyflakes/checker.py\", line 589, in handleNode\n handler(node)\n File \"/usr/lib/python2.7/dist-packages/pyflakes/checker.py\", line 812, in CLASSDEF\n self.handleNode(stmt, node)\n File \"/usr/lib/python2.7/dist-packages/pyflakes/checker.py\", line 589, in handleNode\n handler(node)\n File \"/usr/lib/python2.7/dist-packages/pyflakes/checker.py\", line 696, in RETURN\n if node.value and not self.scope.returnValue:",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "orblivion",
"id": 1432087,
"duplicate_of": null,
"title": "Return statement in class scope after method causes crash",
"comments": [
{
"owner": "orblivion",
"content": "Oops, forgot the last line of the stack trace:\n\nAttributeError: 'ClassScope' object has no attribute 'returnValue'",
"date_created": "2015-03-14T01:53:45Z"
},
{
"owner": "myint",
"content": "I think this was fixed a month previous to this report:\n\nhttps://github.com/pyflakes/pyflakes/pull/13\n\n(It would be cool if this bug tracker was moved to GitHub where the repository is now.)",
"date_created": "2015-04-03T16:21:02Z"
},
{
"owner": "bitglue",
"content": "I can confirm that this is fixed in master, but not yet released. I'll be doing a release soon, hopefully. Thanks for the report.",
"date_created": "2015-05-27T15:03:45Z"
}
],
"importance": "Medium",
"lp_url": "https://bugs.launchpad.net/bugs/1432087",
"date_created": "2015-03-14T01:53:04Z"
},
{
"status": "Triaged",
"security_related": false,
"description": "With the new pyflakes-0.9.0, and python-2.7.10, the following program:\n\n----\nif 1:\n name = 1 # line 2\n del name\n [ name for name in [] ] # line 4\n\nother = 1 # line 6\ndel other\n[ other for other in [] ] # line 8\n----\n\nreports:\n\n /tmp/pf.py:4: list comprehension redefines 'name' from line 2\n\nI see two problems:\n\n* the 'del name' on line 3 should probably prevent the warning. (this sample\n is a stripped-down version of a larger file, in which I added the 'del\n name' to hush an earlier pyflakes complaint)\n\n* the same pattern on lines 6+8 was not reported, the only difference being\n that it occurred at the top-level scope and not in a function scope.\n\nthanks!\n -Brian",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "warner",
"id": 1461208,
"duplicate_of": null,
"title": "inconsistent redefinition complaint, despite 'del'",
"comments": [
{
"owner": "bitglue",
"content": "Ah, yeah. So there was another change, which I can't find now, which addressed this situation (going from memory here):\n\nfoo = \"foo\"\nif False:\n del foo\nprint foo\n\nThis would complain about the final 'print foo' referencing an undefined foo, but as you can see, this code runs just fine.\n\nThe underlying issue here is that pyflakes doesn't have any notion of of conditional branches. Whenever it sees an 'if', 'while', 'try/except', or similar, it just ignores it, and proceeds as if the body of the branch were not in any branch at all. Another case illustrates why:\n\nif False:\n foo = \"foo\"\nprint foo\n\nYou'll notice pyflakes won't complain about this, even though it clearly won't work. Of course usually the conditional expression is something more complicated, and pyflakes can't actually evaluate it since that would require that it is a python interpreter. So it just makes a stupid assumption.\n\nSo, I'll have to think more about how to fix this. I think it's a situation where all cases can't be accurately covered without making some changes to the underlying assumptions that pyflakes makes. Probably it needs to build a graph of the possible code paths and consider the state of the namespace along each possible path through the graph.\n\nI'm calling this medium priority for now since it's hard to fix without making at least one of these cases wrong, and hopefully just a minor annoyance. If that characterization seems wrong, please post some more code examples and we can look at reverting to the previous behavior.",
"date_created": "2015-06-02T20:24:21Z"
}
],
"importance": "Medium",
"lp_url": "https://bugs.launchpad.net/bugs/1461208",
"date_created": "2015-06-02T18:26:40Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Since pyflakes website is down I am reporting this bug in LP.\n\nThe undefined name WindowsError is raised by pyflakes when running on Unix systems.\n\nIt would be nice if pyflakes would trust the developer that such code is only loaded on Windows and allow to check Windows specific Python code on Unix.\n\n----\n\nPlease let me know if you thinks it is a valid problem.\n\nAlso any advice about how to move this bug report upstream is much appreciated.\n\n----\n\nI have also attached a pocket-lint branch that works around this problem.\n\nCheers,",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.6.1",
"owner": "adiroiban",
"id": 764627,
"duplicate_of": null,
"title": "pyflakes complains about missing WindowsError on Unix",
"comments": [
{
"owner": "adiroiban",
"content": "Hi Curtis,\n\nDo you have any suggestion about how this bug should be solved?\n\nDo you want to have it fixed in pocket-lint or in pyflakes?\n\nWhat do you say about the changes from the attached branch?\n\nCheers,\nAdi",
"date_created": "2011-04-18T17:52:38Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/764627",
"date_created": "2011-04-18T13:35:19Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Pyflakes script is installed on Windows without any extension. As a result, on Windows, it has no file type and cannot be executed from a command-line. Consider using setuptools console_script entry_points or adding a .py extension when installing under Windows.\n\nPS C:\\Users\\jaraco> easy_install pyflakes\nSearching for pyflakes\nReading http://pypi.python.org/simple/pyflakes/\nReading http://www.divmod.org/projects/pyflakes\nReading http://www.divmod.org/trac/wiki/DivmodPyflakes\nBest match: pyflakes 0.4.0\nDownloading http://pypi.python.org/packages/source/p/pyflakes/pyflakes-0.4.0.tar.gz#md5=630a72510aae8758f48cf60e4fa17176\nProcessing pyflakes-0.4.0.tar.gz\nRunning pyflakes-0.4.0\\setup.py -q bdist_egg --dist-dir c:\\users\\jaraco\\appdata\\local\\temp\\easy_install-bi_1bs\\pyflakes-0.4.0\\egg-dist-tmp-u6vcvn\nhgtools.SubprocessManager('.') could not find files: abort: There is no Mercurial repository here (.hg not found)!\nzip_safe flag not set; analyzing archive contents...\npyflakes.checker: module references __file__\npyflakes.checker: module references __path__\npyflakes.test.test_undefined_names: module references __file__\npyflakes.test.test_undefined_names: module references __path__\nAdding pyflakes 0.4.0 to easy-install.pth file\nInstalling pyflakes script to C:\\Python\\Scripts\n\nInstalled c:\\python\\lib\\site-packages\\pyflakes-0.4.0-py2.7.egg\nProcessing dependencies for pyflakes\nFinished processing dependencies for pyflakes",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.6.1",
"owner": "jaraco",
"id": 794331,
"duplicate_of": null,
"title": "pyflakes script not executable on Windows",
"comments": [
{
"owner": "mfoord",
"content": "I get this trying to use pyflakes on Windows (Python 2.6 - windows 7 - pyflakes 0.4.0):\n\nC:\\My Dropbox\\RoboRally\\RoboRallyIronPython\n> pyflakes MyBrain.py\nTraceback (most recent call last):\n File \"C:\\Python26\\Scripts\\pyflakes.py\", line 3, in <module>\n from pyflakes.scripts.pyflakes import main\n File \"C:\\Python26\\Scripts\\pyflakes.py\", line 3, in <module>\n from pyflakes.scripts.pyflakes import main\nImportError: No module named scripts.pyflakes\n\nThat is after installation with easy_install. Using pip it doesn't install an executable script for Windows at all.",
"date_created": "2011-08-21T19:25:29Z"
},
{
"owner": "sorin-sbarnea",
"content": "In fact pyflakes doesnt install an executable at all on windows. It must install a pyflakes.bat with the following content\n\n@echo off\nrem Use python to execute the python script having the same name as this batch\nrem file, but without any extension, located in the same directory as this\nrem batch file\npython \"%~dpn0\" %*\n\n\nI have 22 other scripts following the same recipe, or you could try to comeone with an pyflakes.exe but I'm sure it's not what you want.",
"date_created": "2011-12-07T11:12:54Z"
},
{
"owner": "lbolognini",
"content": "The fix for this is super easy. Just rename the Scripts\\pyflakes file something like runpyflakes also if it had an extension it would be nice.\n\nSolution for this bug was found here:\n\nhttp://stackoverflow.com/questions/11444245/how-can-i-get-pyflakes-to-run-on-windows",
"date_created": "2012-09-08T00:41:03Z"
},
{
"owner": "florent.x",
"content": "The missing entry_point is proposed in this patch:\nhttp://bazaar.launchpad.net/~witsch/divmod.org/Pyflakes/revision/2699",
"date_created": "2013-01-08T10:38:32Z"
},
{
"owner": "florent.x",
"content": "Merged with revision 60 (rev 59.1.4)",
"date_created": "2013-01-27T16:52:25Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/794331",
"date_created": "2011-06-08T00:53:20Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Such code:\n\ndef f(a):\n if a:\n def g(): pass\n else:\n def g(): do_something()\n\nwill issue a warning with a redefinition of g",
"tags": [],
"duplicates": [
969920
],
"assignee": "florent.x",
"milestone": "0.6.1",
"owner": "fijal",
"id": 800691,
"duplicate_of": null,
"title": "False positive redefinition with functions defined in conditionals",
"comments": [
{
"owner": "jtaylor",
"content": "does not only affect closures but any conditional:\n\nif True:\n def f():\n pass\nelse:\n def f():\n pass\n\nredefinition of function 'f' from line 2",
"date_created": "2012-03-15T20:40:33Z"
},
{
"owner": "exarkun",
"content": "I expect this is a duplicate of https://bugs.launchpad.net/pyflakes/+bug/916264\n",
"date_created": "2012-03-15T21:19:57Z"
},
{
"owner": "adiroiban",
"content": "It looks like #916264 is about RedefinedWhileUnused while this is about the generic Redefined\n\n\nMaybe they can be solved from one go... I will check to see what can be done.",
"date_created": "2012-04-30T15:07:15Z"
},
{
"owner": "mirko-dziadzka+launchpad-net",
"content": "This also affect try/except statement like:\n\ntry:\n from a import f\nexcept ImportError:\n from b import f",
"date_created": "2012-11-01T12:11:11Z"
},
{
"owner": "saperski",
"content": "I think I have a fix for this problem for a slightly different fork of pyflakes here: https://github.com/kevinw/pyflakes/pull/28",
"date_created": "2013-01-06T02:19:26Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/800691",
"date_created": "2011-06-22T13:22:56Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Code from: http://docs.python.org/library/functions.html#property\n\n-------------------------------------- foo.py\n\nclass C(object):\n\u00a0\u00a0\u00a0\u00a0def __init__(self):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self._x = None\n\n\u00a0\u00a0\u00a0\u00a0@property\n\u00a0\u00a0\u00a0\u00a0def x(self):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"\"\"I'm the 'x' property.\"\"\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return self._x\n\n\u00a0\u00a0\u00a0\u00a0@x.setter\n\u00a0\u00a0\u00a0\u00a0def x(self, value):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0self._x = value\n\n\u00a0\u00a0\u00a0\u00a0@x.deleter\n\u00a0\u00a0\u00a0\u00a0def x(self):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0del self._x\n\n---------------------------------------------\n\npyflakes output is\n\n$ pyflakes foo.py\nfoo.py:11: redefinition of function 'x' from line 6\nfoo.py:15: redefinition of function 'x' from line 11",
"tags": [
"decorator",
"property",
"redefinition"
],
"duplicates": [],
"assignee": null,
"milestone": "0.6.1",
"owner": "cassapanco",
"id": 812958,
"duplicate_of": null,
"title": "property decorator -> redefinition of function",
"comments": [
{
"owner": "kamil.paral",
"content": "I can confirm this problem.",
"date_created": "2012-02-08T09:23:17Z"
},
{
"owner": "kisielk",
"content": "There's a patch in a pending pull request on the kevinw/pyflakes fork on github that addresses this issue:\n\nhttps://github.com/ervandew/pyflakes/commit/b971f2775500b4154619dc5d71ba77fc7e4efdf6",
"date_created": "2012-02-21T00:07:09Z"
},
{
"owner": "exarkun",
"content": "The feature seems questionable to me. However, it would be easier to evaluate the implementation if there were unit tests for the change.\n",
"date_created": "2012-02-21T13:56:06Z"
},
{
"owner": "glyph",
"content": "It looks like this was fixed - inadvertently perhaps? - by <http://bazaar.launchpad.net/~divmod-dev/divmod.org/trunk/revision/2685>.",
"date_created": "2012-03-31T22:23:53Z"
},
{
"owner": "mestrelion",
"content": "Any news on when this fix will be released in Ubuntu?",
"date_created": "2012-11-22T06:31:17Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/812958",
"date_created": "2011-07-19T15:21:19Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "If you have a Python program like this:\n\nclass Foo: pass\nclass Foo: pass\n\nPyflakes won't emit a warning, but it should.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.6.1",
"owner": "glyph",
"id": 823369,
"duplicate_of": null,
"title": "no warning for duplicate classes",
"comments": [
{
"owner": "hjd",
"content": "Confirmed. Pyflakes 0.5.0 prints no warning on a file containing your example.\r\n\r\nPylint warns about the duplicate class though.",
"date_created": "2012-12-30T20:00:28Z"
},
{
"owner": "florent.x",
"content": "Fixed in trunk.\nhttp://bazaar.launchpad.net/~divmod-dev/divmod.org/trunk/revision/2685",
"date_created": "2013-01-08T10:51:23Z"
},
{
"owner": "florent.x",
"content": "Of course I linked the old repository...\n\nThe current one is:\nhttp://bazaar.launchpad.net/~divmod-dev/pyflakes/trunk/revision/42",
"date_created": "2013-01-08T11:22:12Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/823369",
"date_created": "2011-08-09T15:52:08Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "With the attached example file, pyflakes reports\n\npf.py:6: redefinition of unused 'connect' from line 3\npf.py:6: redefinition of unused 'PARSE_DECLTYPES' from line 3\npf.py:6: redefinition of unused 'PARSE_COLNAMES' from line 3\n\nThey're not redefinitions, but fallbacks in case defining them the first time fails. I don't know if there's a way to catch this, but it's worth noting.",
"tags": [
"except",
"import",
"redefinition",
"try"
],
"duplicates": [
1035108
],
"assignee": "florent.x",
"milestone": "0.6.1",
"owner": "4-launchpad-tim-thechases-com",
"id": 916264,
"duplicate_of": null,
"title": "Cascading try/except imports report duplicates",
"comments": [
{
"owner": "4-launchpad-tim-thechases-com",
"content": "",
"date_created": "2012-01-13T22:05:38Z"
},
{
"owner": "adiroiban",
"content": "This is on the TODO list: pyflakes.test.test_imports.Test.test_tryingMultipleImports",
"date_created": "2012-04-30T15:41:39Z"
},
{
"owner": "fpinard",
"content": "The same duplication warning occurs if one assigns the import name, like in:\n\ntry:\n import signal\nexcept ImportError:\n signal = None\n\nThis code comes from a program which sometimes runs under Jython, so it could quickly test if \"signal\" was available.\n\nFran\u00e7ois",
"date_created": "2012-06-10T10:49:24Z"
},
{
"owner": "saperski",
"content": "I think I have a fix for this problem for a slightly different fork of pyflakes here: https://github.com/kevinw/pyflakes/pull/28\n\n",
"date_created": "2013-01-06T02:19:08Z"
},
{
"owner": "zbyszek-in",
"content": "Tested this on multi-import from http://lxml.de/tutorial.html and it seems to work well.\n\nOTOH, stuff like:\nchoice = sys.getenv('CHOICE')\nif choice == 'A':\n import A as backend\n\nif choice == 'B':\n import B as backend\n\ndon't work, as expected.\n",
"date_created": "2013-01-08T19:17:47Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/916264",
"date_created": "2012-01-13T22:05:38Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "A user came into the #vim channel on IRC looking for help with the pyflakes plugin. I tracked down the error to a bug(?) in pyflakes: it doesn't work in a Turkish locale. Instead you get\n\nAttributeError: 'Checker' object has no attribute 'ATTRiBUTE'\n\nScreenshot of the original error: http://i.imgur.com/gAfRB.png\n\nThe user's locale:\nLANG=tr_TR.UTF-8\nLANGUAGE=\nLC_CTYPE=\"tr_TR.UTF-8\"\nLC_NUMERIC=\"tr_TR.UTF-8\"\nLC_TIME=\"tr_TR.UTF-8\"\nLC_COLLATE=\"tr_TR.UTF-8\"\nLC_MONETARY=\"tr_TR.UTF-8\"\nLC_MESSAGES=\"tr_TR.UTF-8\"\nLC_PAPER=\"tr_TR.UTF-8\"\nLC_NAME=\"tr_TR.UTF-8\"\nLC_ADDRESS=\"tr_TR.UTF-8\"\nLC_TELEPHONE=\"tr_TR.UTF-8\"\nLC_MEASUREMENT=\"tr_TR.UTF-8\"\nLC_IDENTIFICATION=\"tr_TR.UTF-8\"\nLC_ALL=\n\nThis workaround fixed the error for that user:\n\n<mgedmin> edit that pyflakes/checker.py file, find line 317 (actual number might differ depending on the version) -- the line that does 'nodeType = node.__class__.__name__.upper()'\n<mgedmin> change it to 'nodeType = node.__class__.__name__.upper().replace(\"i\", \"I\")'",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7",
"owner": "mgedmin",
"id": 942603,
"duplicate_of": null,
"title": "AttributeError in a Turkish locale",
"comments": [
{
"owner": "orc-avs",
"content": "That bothered me, too. This happens resulting from a well-known problem for Turkish locale. Lower 'i' stays as 'i' on upper() function, so 'assign' becomes 'ASSiGN' instead of 'ASSIGN' and that causes further error when getattr(node, 'ASSiGN') is called. I don't know what upper() is used for. But you should either accept this workaround or use locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') at the top of the code somewhere as upper() and lower() functions are locale-dependent.",
"date_created": "2012-11-18T13:12:27Z"
},
{
"owner": "florent.x",
"content": "Committed on trunk, rev 77",
"date_created": "2013-03-30T17:59:17Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/942603",
"date_created": "2012-02-28T13:28:30Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Hello,\nI'm reporting http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674797:\n\n>>>\nIf the tested file contains invalid \\x escape, pyflakes fails with traceback:\n\n$ pyflakes test.py\nTraceback (most recent call last):\n File \"/usr/bin/pyflakes\", line 5, in <module>\n sys.exit(main(sys.argv[1:]))\n File \"/usr/lib/pymodules/python2.7/pyflakes/scripts/pyflakes.py\", line 92, in main\n warnings += checkPath(arg)\n File \"/usr/lib/pymodules/python2.7/pyflakes/scripts/pyflakes.py\", line 74, in checkPath\n return check(fd.read(), filename)\n File \"/usr/lib/pymodules/python2.7/pyflakes/scripts/pyflakes.py\", line 28, in check\n tree = compile(codeString, filename, \"exec\", _ast.PyCF_ONLY_AST)\nValueError: invalid \\x escape\n<<<\n\nwith test.py being:\n\n>>>\nfoo = '\\xyz'\n<<<\n\nRegards,\nSandro",
"tags": [],
"duplicates": [],
"assignee": "florent.x",
"milestone": "0.6.1",
"owner": "morph-debian",
"id": 1005602,
"duplicate_of": null,
"title": "ValueError: invalid \\x escape",
"comments": [],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1005602",
"date_created": "2012-05-28T17:21:16Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Hello,\nI'm reporting http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674796:\n\n>>>\n\nIf the tested file contains null bytes, pyflakes fails with traceback:\n\n$ pyflakes test.py\nTraceback (most recent call last):\n File \"/usr/bin/pyflakes\", line 5, in <module>\n sys.exit(main(sys.argv[1:]))\n File \"/usr/lib/pymodules/python2.7/pyflakes/scripts/pyflakes.py\", line 92, in main\n warnings += checkPath(arg)\n File \"/usr/lib/pymodules/python2.7/pyflakes/scripts/pyflakes.py\", line 74, in checkPath\n return check(fd.read(), filename)\n File \"/usr/lib/pymodules/python2.7/pyflakes/scripts/pyflakes.py\", line 28, in check\n tree = compile(codeString, filename, \"exec\", _ast.PyCF_ONLY_AST)\nTypeError: compile() expected string without null bytes\n<<<\n\nAttached the test file.\n\nRegards,\nSandro",
"tags": [],
"duplicates": [],
"assignee": "florent.x",
"milestone": "0.6.1",
"owner": "morph-debian",
"id": 1005603,
"duplicate_of": null,
"title": "TypeError: compile() expected string without null bytes",
"comments": [
{
"owner": "morph-debian",
"content": "",
"date_created": "2012-05-28T17:23:07Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1005603",
"date_created": "2012-05-28T17:23:07Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "The setup.py could optionally use distribute/setuptools if it is available in the path.\n\nThe library distribute (or setuptools) is very common in the Python ecosystem, and many tools depend on them, like \"pip install\", \"virtualenv\", \"zc.buildout\", ...\nOf course there's some criticism about these tools, but they exist, they are compatible, and they work fine for a lot of developers.\nThey fill a use case as explained below.\n\nThe benefit of using distribute/setuptools is the additional verbs which are available, like:\n\n $ python setup.py test\n\nThis allows to run the tests, and it takes care of installing the 'test_requires' dependencies without other action. Anyone can run the tests without any assumption about the test framework, and without digging through the source code to know which libraries are required (nose, py.test, twisted.trial, unittest, etc...).\nThis particular use case is not supported by the distutils library.\n\nAnother verb which is widely used but not supported by distutils:\n\n $ python setup.py develop\n\n\nAnd the best is that it is fully optional.\nWhen the distribute/setuptools package is not installed, it imports 'setup' from distutils and it behaves exactly the same as before.\n\nFor the record, there are some users which already suggested this change: https://github.com/kevinw/pyflakes/pull/19",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.6.1",
"owner": "florent.x",
"id": 1097379,
"duplicate_of": null,
"title": "support \"setup.py test\" and \"setup.py develop\"",
"comments": [],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1097379",
"date_created": "2013-01-08T18:09:22Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "The example below reports incorrectly \"undefined name in __all__\"\n\n try:\n from _codecs import *\n except ImportError as why:\n raise SystemError('Failed to load the builtin codecs: %s' % why)\n\n __all__ = [\"register\", \"lookup\", \"register_error\", \"lookup_error\"]\n\nThe \"import *\" should disable the reporting of undefined name, here.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.6.1",
"owner": "florent.x",
"id": 1106832,
"duplicate_of": null,
"title": "false report of undefined name in __all__ when import * is used",
"comments": [
{
"owner": "florent.x",
"content": "The feature about \"undefined name in __all__\" was added here:\n\nhttp://bazaar.launchpad.net/~divmod-dev/divmod.org/pyflakes-all-2826/revision/2614/Pyflakes/pyflakes/checker.py",
"date_created": "2013-01-27T12:13:43Z"
},
{
"owner": "florent.x",
"content": "Fixed in r59.1.3 and merged with revision 60",
"date_created": "2013-01-27T16:55:25Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1106832",
"date_created": "2013-01-27T11:27:31Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "This would be useful for projects using gettext, that add '_' as a built-in (for example).\n\nWorkaround in flake8:\nhttps://bitbucket.org/tarek/flake8/commits/b8fe4f73e6c3e875107640e6d26f19c2c7462b42\n\nWorkaround in Ninja-IDE:\nhttps://github.com/ninja-ide/ninja-ide/issues/1087#issuecomment-12767381",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.6.1",
"owner": "florent.x",
"id": 1107587,
"duplicate_of": null,
"title": "Support additional built-ins",
"comments": [],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1107587",
"date_created": "2013-01-28T07:27:24Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "bin/pyflakes is missing from the 0.7 tarball, and the test suite fails without it:\n\n$ tar xf pyflakes-0.7.tar.gz\n$ cd pyflakes-0.7\n$ python setup.py test\n[...]\n======================================================================\nFAIL: test_errors (pyflakes.test.test_api.IntegrationTests)\n----------------------------------------------------------------------\n[...]\nFirst differing element 1:\n/usr/bin/python: can't open file '/path/to/pyflakes-0.7/pyflakes/../bin/pyflakes': [Errno 2] No such file or directory\n[...etc other failing tests due to the same error...]",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7.1",
"owner": "vskytta",
"id": 1170461,
"duplicate_of": null,
"title": "bin/pyflakes missing from 0.7 tarball",
"comments": [
{
"owner": "florent.x",
"content": "Thank you for reporting it.\r\n\r\nWeird, I don't see any change since 0.6.1 which explain this exclusion (except the upgrade of distribute on my laptop).\r\nI'll have a look.",
"date_created": "2013-04-18T21:22:44Z"
},
{
"owner": "florent.x",
"content": "I confirmed some discrepancies when the tarball is generated from distribute versus distutils.core.\r\n\r\nIt should be fixed with revision 93",
"date_created": "2013-04-21T11:11:39Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1170461",
"date_created": "2013-04-18T19:19:37Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "pyflakes.test.test_api.CheckTests.test_invalidEscape() fails with Python >=3.2.\n\n======================================================================\nFAIL: test_invalidEscape (pyflakes.test.test_api.CheckTests)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/tmp/pyflakes-0.7.2/pyflakes/test/test_api.py\", line 395, in test_invalidEscape\n sourcePath, [decoding_error])\n File \"/tmp/pyflakes-0.7.2/pyflakes/test/test_api.py\", line 252, in assertHasErrors\n (count, err.getvalue()), (len(errorList), ''.join(errorList)))\nAssertionError: Tuples differ: (1, \"/tmp/tmprzp_3x:1: (unicod... != (1, \"/tmp/tmprzp_3x:1: (unicod...\n\nFirst differing element 1:\n/tmp/tmprzp_3x:1: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \\xXX escape\nfoo = '\\xyz'\n ^\n\n/tmp/tmprzp_3x:1: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-2: truncated \\xXX escape\nfoo = '\\xyz'\n ^\n\n\n (1,\n- \"/tmp/tmprzp_3x:1: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \\\\xXX escape\\nfoo = '\\\\xyz'\\n ^\\n\")\n? ^\n\n+ \"/tmp/tmprzp_3x:1: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-2: truncated \\\\xXX escape\\nfoo = '\\\\xyz'\\n ^\\n\")\n? ^\n\n\n----------------------------------------------------------------------\nRan 544 tests in 1.801s\n\nFAILED (failures=1, skipped=23)",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7.3",
"owner": "arfrever-fta",
"id": 1172463,
"duplicate_of": null,
"title": "test_api.CheckTests.test_invalidEscape() fails with Python >=3.2.4",
"comments": [
{
"owner": "florent.x",
"content": "Thank you for the report.\r\n\r\nHowever it works in some environments:\r\n - OS X, Python 3.2.3\r\n - Travis-CI https://travis-ci.org/pyflakes/pyflakes/builds/6597546\r\n\r\nCould you provide details to help investigate?\r\n\r\n - which OS\r\n - exact Python version which fails\r\n python -c 'import sys; print(sys.version)'\r\n - which version(s) of Python are ok\r\n - any other hint...\r\n",
"date_created": "2013-04-24T20:46:36Z"
},
{
"owner": "arfrever-fta",
"content": "It might occur only with very recent versions. Please try 3.2.4.\nI tested with both 3.2.4 and 3.3.1+ (a snapshot from between 3.3.1 and 3.3.2) on Gentoo GNU/Linux.\nAll tests pass with Python 2.6.8, 2.7.4+ and 3.1.5",
"date_created": "2013-04-24T20:58:34Z"
},
{
"owner": "arfrever-fta",
"content": "This bug also occurs in pyflakes-0.6.1.\nPreviously I tested pyflakes-0.6.1 on 2013-01-29 and then test suite passed with some snapshot of Python 3.2 from january.",
"date_created": "2013-04-24T21:01:20Z"
},
{
"owner": "florent.x",
"content": "Now I can confirm the issue with Python 3.3.1\r\nThe test suite should be updated to accommodate this change.\r\n\r\n$ python -c 'import sys; print(sys.version)'\r\n3.3.1 (default, Apr 21 2013, 17:17:19) \r\n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]\r\n\r\nPython 3.3.0 and Python 3.2.3 are not affected.",
"date_created": "2013-04-24T21:25:21Z"
},
{
"owner": "johneed",
"content": "It occurs in 3.2.4, I just ran it.",
"date_created": "2013-05-31T06:16:28Z"
},
{
"owner": "florent.x",
"content": "It should be fixed in trunk",
"date_created": "2013-06-15T12:13:01Z"
},
{
"owner": "arfrever-fta",
"content": "I confirm that revision 0c4405d946c6c1be9be3e3a52191ab23968d1244 fixed this bug.",
"date_created": "2013-06-15T15:34:49Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1172463",
"date_created": "2013-04-24T20:23:26Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Example file:\n\ndef func():\n \"\"\"\n A docstring\n >>> func()\n 1\n >>> _\n 1\n \"\"\"\n return 1\n\n\npyflakes reports\n\ntest.py:6: undefined name '_'\n\nBut _ is a valid variable name in doctests (python -m doctest test.py passes)",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8",
"owner": "asmeurer",
"id": 1178096,
"duplicate_of": null,
"title": "_ is a valid variable name in doctests",
"comments": [
{
"owner": "asmeurer",
"content": "Just glancing at the code, I think it's easy to fix. How do you send patches using Launchpad?",
"date_created": "2013-05-09T23:58:02Z"
},
{
"owner": "florent.x",
"content": "thank you for the bug report.\n\nYou can propose a patch either on Launchpad or GitHub.\n\nLaunchpad way:\n * clone the repository\n : bzr branch lp:pyflakes pyflakes_fix\n * commit the fix\n : bzr commit -m \"_ is a variable name in doctests\" --fixes lp:1178096\n * publish the branch\n : bzr push lp:~asmeurer/pyflakes/1178096-underscore\n * visit the Launchpad website, view the new branch and click \"propose for merging\"\n https://code.launchpad.net/pyflakes\n",
"date_created": "2013-05-10T07:49:36Z"
},
{
"owner": "asmeurer",
"content": "Oh I didn't realize you were on github. I would have just done that in the first place if I knew. ",
"date_created": "2013-05-10T16:12:51Z"
},
{
"owner": "asmeurer",
"content": "OK, on further inspection, this isn't as easy to fix as I thought, or at least not if I want to fix it right. \n\nMy plan was to just add _ to the list of defined names when in a doctest. But that's not entirely correct. It is defined only if a previous statement had a result. So for example, _ won't be defined if it's in the first line of the doctest. It also won't be defined if all the executions were assignments or function definitions. Is there a nice way to check this in the ast, or do I just need to enumerate all the cases?\n\nBy the way, would you actually prefer a patch on GitHub or here on Launchpad. GitHub is way easier for me, because I know git and am used to the pull request interface (and it's IMO better anyway), but I'll do it here on Launchpad if that's easier for you (assuming I can figure it out).",
"date_created": "2013-05-10T18:20:21Z"
},
{
"owner": "florent.x",
"content": "The issue reported here is fixed in trunk.\r\n\r\nActually _ is only defined after the first statement which returns a value not equal to None, as explained by ameurer in the previous comment.\r\n\r\nHowever, the static analysis provided by the AST is not able to detect such condition.\r\n\r\nWe prefer to avoid false-positives here.",
"date_created": "2014-03-22T16:03:04Z"
},
{
"owner": "asmeurer",
"content": "Hmm, actually, playing around with it, it looks like the doctest runner *always* defines _. If nothing has been evaluated yet, it is set to None (this is unlike the interactive Python session where the behavior you described takes place).",
"date_created": "2014-03-22T16:19:39Z"
},
{
"owner": "florent.x",
"content": "So the fix is better than I thought.\n\nThank you for this update.",
"date_created": "2014-03-22T16:38:39Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1178096",
"date_created": "2013-05-09T05:45:48Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Pyflakes reports \"undefined name A\" on the third line of this code:\n\nclass C(object):\n A = [1, 2, 3]\n B = dict((i, str(i)) for i in A)\n\nThis construction works in every version of Python since at least 2.5. (real-world use case from which this was extracted: https://github.com/facebook/tornado/blob/master/tornado/options.py#L444)",
"tags": [],
"duplicates": [
1190075
],
"assignee": null,
"milestone": "0.7.3",
"owner": "ben-darnell",
"id": 1184732,
"duplicate_of": null,
"title": "False positive on comprehensions in class scope",
"comments": [
{
"owner": "asmeurer",
"content": "Changing the except clause at line 444 to also catch ClassScope fixes it, i.e.,\n\ndiff --git a/pyflakes/checker.py b/pyflakes/checker.py\nindex ed9381e..6ed7f9c 100644\n--- a/pyflakes/checker.py\n+++ b/pyflakes/checker.py\n@@ -441,7 +441,7 @@ class Checker(object):\n importStarred = self.scope.importStarred\n for scope in self.scopeStack[-2:0:-1]:\n importStarred = importStarred or scope.importStarred\n- if not isinstance(scope, FunctionScope):\n+ if not isinstance(scope, (FunctionScope, ClassScope)):\n continue\n try:\n scope[name].used = (self.scope, node)\n\nBut I'm not sure what the implications of this change are. It seems to lead to some test failures (which I cannot understand how to read).",
"date_created": "2013-05-27T21:08:12Z"
},
{
"owner": "florent.x",
"content": "Another test case from issue #1190075 (marked duplicate)\n\nclass A:\n T = range(10)\n\n X = {x for x in T}\n Y = {x:x for x in T}\n Z = (x for x in T)\n L = [x for x in T]\n\nI tried the patch proposed by @asmeurer and it fixes the issue.\nHowever it gives a failure in another part of the test suite. Under investigation...",
"date_created": "2013-06-15T10:38:57Z"
},
{
"owner": "florent.x",
"content": "Patch attached.",
"date_created": "2013-06-15T12:05:37Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1184732",
"date_created": "2013-05-27T19:38:03Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "It would be nice if you could tag releases in git. It's useful if you want to build releases from git.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7.3",
"owner": "dwnarvaez",
"id": 1198323,
"duplicate_of": null,
"title": "Tag 0.7.3 in git",
"comments": [
{
"owner": "florent.x",
"content": "Done.\r\n\r\nThank you.",
"date_created": "2014-01-17T10:00:02Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1198323",
"date_created": "2013-07-05T20:34:29Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "for i in range(i):\n print i\n\nPyflakes doesn't report any errors here, even though the i in range(i) is undefined. If I change the loop variable to j, it reports it as undefined.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8.1",
"owner": "asmeurer",
"id": 1205907,
"duplicate_of": null,
"title": "Undefined variable in for loop not caught",
"comments": [
{
"owner": "florent.x",
"content": "Thank you for reporting this issue.\r\nIt's fixed in trunk (planned for 0.8.1)\r\n\r\nhttps://github.com/pyflakes/pyflakes/commit/3d54e69e337481970faac3eae60ef35f4cfc6719",
"date_created": "2014-03-29T22:37:44Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1205907",
"date_created": "2013-07-28T19:50:20Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Compare these outputs\n\n$pyflakes test.py\ntest.py:6: invalid syntax\n print 1\n ^\n\n$python test.py\n File \"test.py\", line 6\n print 1\n ^\nSyntaxError: invalid syntax\n\nPython correctly puts the caret under the 1. Pyflakes puts it one character past the 1",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8",
"owner": "asmeurer",
"id": 1249873,
"duplicate_of": null,
"title": "Wrong caret position on syntax error",
"comments": [
{
"owner": "asmeurer",
"content": "Fixed at https://github.com/pyflakes/pyflakes/pull/15",
"date_created": "2013-11-13T01:34:25Z"
},
{
"owner": "florent.x",
"content": "Thank you for the report. This is fixed in trunk on Github.",
"date_created": "2014-01-17T09:09:51Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1249873",
"date_created": "2013-11-11T01:11:33Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Sample code:\n\n__all__ = ('urlparse',)\nfrom urlparse import urlparse\n\nOutput:\n\nF401: 'urlparse' imported but unused\n\nExpected:\n\nNo error, because 'urlparse' is used - it is intentionally imported for providing out to other packages. These intentions should be obvious from __all__.\n\nNote:\n\nActually I am using https://github.com/dreadatour/Flake8Lint, but I guess this warning comes from PyFlakes originally. Please correct me if I am wrong.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8",
"owner": "honzajavorek",
"id": 1266446,
"duplicate_of": null,
"title": "F401 imported but unused shouldn't appear if the token is mentioned in __all__",
"comments": [
{
"owner": "icordasc",
"content": "That error is entirely correct as best as I can tell. The way I do what you're trying to is:\n\nfrom urlparse import urlparse\n\n__all__ = (urlparse,)\n\nIn other words, I use the function object itself, not a string to represent it.",
"date_created": "2014-01-06T13:48:03Z"
},
{
"owner": "florent.x",
"content": "Actually the issue is that Pyflakes expects a List in \"__all__\" , not a Tuple.\r\nThe documentation allows both Tuple or List, however it is almost always a List.\r\n\r\nProbably I will patch the code to accept Tuple as well.\r\n\r\nPS: Ian, you should re-read the documentation for __all__, it expects a list of names, not a list of objects ;) ",
"date_created": "2014-01-17T09:32:40Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1266446",
"date_created": "2014-01-06T12:11:22Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "pyflakes appears to get confused when a method named 'foo' has default args that refer to a module named 'foo'. Example:\n\n$ cat bad-unused-import.py\nimport foo\n\nclass Thing(object):\n def foo(self, parser=foo.parse_foo):\n pass\n\n$ pyflakes bad-unused-import.py\nbad-unused-import.py:1: 'foo' imported but unused\n\nI'm positive this is valid Python, because 'foo' the method isn't in scope yet when processing those default args. So 'foo.parse_foo' refers to something in the 'foo' module, as intended. So the module 'foo' really is being used here!\n\nThere's an easy workaround: \"import foo as foo_\". But that's yucky. It would be nice if pyflakes accepted this code as it stands.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8.1",
"owner": "gward",
"id": 1270952,
"duplicate_of": null,
"title": "spurious \"imported but unused\" when method name shadows module name",
"comments": [
{
"owner": "florent.x",
"content": "Thank you for this report.\r\n\r\nIt's fixed in trunk\r\n\r\nhttps://github.com/pyflakes/pyflakes/commit/20c7c950a79f24ad53cfc874689e32b903493f36",
"date_created": "2014-03-30T02:55:29Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1270952",
"date_created": "2014-01-20T21:29:48Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "This is on pyflakes==0.7.3 in python 2.6\n\n```\nTraceback (most recent call last):\n File \"/Users/peterbe/virtualenvs/socorro/bin/pyflakes\", line 9, in <module>\n load_entry_point('pyflakes==0.7.3', 'console_scripts', 'pyflakes')()\n File \"/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/pyflakes/api.py\", line 128, in main\n warnings = checkRecursive(args, reporter)\n File \"/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/pyflakes/api.py\", line 119, in checkRecursive\n warnings += checkPath(sourcePath, reporter)\n File \"/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/pyflakes/api.py\", line 86, in checkPath\n return check(codestr, filename, reporter)\n File \"/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/pyflakes/api.py\", line 58, in check\n w = checker.Checker(tree, filename)\n File \"/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/pyflakes/checker.py\", line 253, in __init__\n self.handleChildren(tree)\n File \"/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/pyflakes/checker.py\", line 520, in handleChildren\n self.handleNode(node, tree)\n File \"/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/pyflakes/checker.py\", line 555, in handleNode\n handler(node)\n File \"/Users/peterbe/virtualenvs/socorro/lib/python2.6/site-packages/pyflakes/checker.py\", line 779, in CLASSDEF\n for keywordNode in node.keywords:\nAttributeError: 'ClassDef' object has no attribute 'keywords'\n```\n\nI was going to include a file that it happens on but I noticed it happens on EVERY file. Is it simply a matter of breakage in python 2.6?",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8",
"owner": "mail-peterbe",
"id": 1277606,
"duplicate_of": null,
"title": "AttributeError: 'ClassDef' object has no attribute 'keywords'",
"comments": [
{
"owner": "mail-peterbe",
"content": "I tried the same file using the same pyflakes==0.7.3 in a python 2.7 virtualenv and no errors. (Well, no exceptions that is)",
"date_created": "2014-02-07T17:07:47Z"
},
{
"owner": "alejandrosantana",
"content": "I have this same warning, but only if pyflakes find no error in the source code.\n Python 2.7 (no virtualenv), also installed Python 3\n SO: Kubuntu 13.10\n Name: pyflakes\n Version: 0.7.3\n Location: /usr/local/lib/python2.7/dist-packages\n\nThe error message:\n\nTraceback (most recent call last):\n File \"/usr/local/bin/pyflakes\", line 9, in <module>\n load_entry_point('pyflakes==0.7.3', 'console_scripts', 'pyflakes')()\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/api.py\", line 128, in main\n warnings = checkRecursive(args, reporter)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/api.py\", line 119, in checkRecursive\n warnings += checkPath(sourcePath, reporter)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/api.py\", line 86, in checkPath\n return check(codestr, filename, reporter)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/api.py\", line 58, in check\n w = checker.Checker(tree, filename)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/checker.py\", line 253, in __init__\n self.handleChildren(tree)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/checker.py\", line 520, in handleChildren\n self.handleNode(node, tree)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/checker.py\", line 555, in handleNode\n handler(node)\n File \"/usr/local/lib/python2.7/dist-packages/pyflakes/checker.py\", line 779, in CLASSDEF\n for keywordNode in node.keywords:\nAttributeError: 'ClassDef' object has no attribute 'keywords'",
"date_created": "2014-02-17T04:11:53Z"
},
{
"owner": "stefan-tjarks",
"content": "Got the same error in one of my virtual envs. Turned out that for some reason pyflakes thinks it is running not PY2.\nI changed\n\ntry:\n builtin_vars = dir(__import__('builtins'))\n PY2 = False\nexcept ImportError:\n builtin_vars = dir(__import__('__builtin__'))\n PY2 = True\n\nwith\n\n builtin_vars = dir(__import__('__builtin__'))\n PY2 = True\n\nin pyflakes/checker.py and that fixed it. Guess some other third party library is messing around with 'builtins' but did not really dig into that.",
"date_created": "2014-03-12T23:18:34Z"
},
{
"owner": "matthew-russell",
"content": "On my machine I get the same error.\nIt's due to the following file being present:\n\n~/.local/lib/python2.7/site-packages/builtins.py\n\nSearches:\n$ find ~/.local/lib/python2.7/site-packages/ -type f -exec grep -Hn builtins.py {} \\;\n/home/matthew/.local/lib/python2.7/site-packages/pies2overrides-2.6.1-py2.7.egg-info/SOURCES.txt:2:builtins.py\n/home/matthew/.local/lib/python2.7/site-packages/pies2overrides-2.6.1-py2.7.egg-info/installed-files.txt:2:../builtins.py\n/home/matthew/.local/lib/python2.7/site-packages/pies2overrides-2.6.1-py2.7.egg-info/installed-files.txt:19:../builtins.pyc\n\n$ find /home/matthew/.local/lib/python2.7/site-packages/ -type f -name requires.txt -exec grep -Hn pies {} \\;\n/home/matthew/.local/lib/python2.7/site-packages/pies-2.6.1-py2.7.egg-info/requires.txt:1:pies2overrides\n/home/matthew/.local/lib/python2.7/site-packages/isort-3.6.2-py2.7.egg-info/requires.txt:1:pies>=2.6.0\n\n$ find /home/matthew/.local/lib/python2.7/site-packages/ -type f -name requires.txt -exec grep -Hn pies {} \\;\n/home/matthew/.local/lib/python2.7/site-packages/pies-2.6.1-py2.7.egg-info/requires.txt:1:pies2overrides\n/home/matthew/.local/lib/python2.7/site-packages/isort-3.6.2-py2.7.egg-info/requires.txt:1:pies>=2.6.0\n\n\nThis has the sole line:\n\nfrom __builtins__ import *\n\nThe offending module on my system is isort.\n\nIn #3 Stefan shows the call site in pyflakes where this is a problem.\nPersonally I think isort is using the above to try and bridge the 2/3 divide,\nbut should probably add a compat module.\n\npyflakes should use:\nPY2 = sys.version.starswith('2') or similar.\n\nWill raise a bug in both projects.\n",
"date_created": "2014-03-15T18:32:51Z"
},
{
"owner": "matthew-russell",
"content": "Should clarify that it is the 'pies' package that has the from __builtins__ import * stuff, not isort.",
"date_created": "2014-03-15T18:51:33Z"
},
{
"owner": "matthew-russell",
"content": "hmm, on relection, I don't think pies can be blamed really since it is a compatibility library after all (should of checked first).\n ",
"date_created": "2014-03-15T19:00:19Z"
},
{
"owner": "florent.x",
"content": "The Python version detection is more robust in trunk.",
"date_created": "2014-03-22T16:28:54Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1277606",
"date_created": "2014-02-07T17:06:06Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Please see:\nhttps://bugs.launchpad.net/pyflakes/+bug/1277606/comments/4\n\nI think pyflakes could use:\n\nPY2 = sys.version.startswith('2')\n\ninstead of the try/except in checker.py ?",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8",
"owner": "matthew-russell",
"id": 1292942,
"duplicate_of": null,
"title": "Don't rely on builtins to determine python version?",
"comments": [
{
"owner": "florent.x",
"content": "Fixed in trunk, thank you",
"date_created": "2014-03-22T16:32:39Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1292942",
"date_created": "2014-03-15T18:35:28Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "When doing work for oslo.messaging project, I've found behaviour that seems like a bug. You can find the code that triggered it at: https://github.com/booxter/oslo.messaging/tree/self-config-with-fixture\n\nWhen I run 'tox -e pep8' for the project with my patch applied (HEAD of the branch), I get the following:\n\n[ihrachys@dhcp130-159 oslo.messaging]$ tox -e pep8\nGLOB sdist-make: /home/ihrachys/proj/oslo.messaging/setup.py\npep8 inst-nodeps: /home/ihrachys/proj/oslo.messaging/.tox/dist/oslo.messaging-1.3.0a9.16.g7944d9d.zip\npep8 runtests: commands[0] | flake8\n./tests/test_transport.py:147:1: F811 redefinition of unused 'transport' from line 24\n transport = messaging.get_transport(self.conf, **kwargs)\n^\nERROR: InvocationError: '/home/ihrachys/proj/oslo.messaging/.tox/pep8/bin/flake8'\n__________________________________________________________________ summary __________________________________________________________________\nERROR: pep8: commands failed\n\nIt seems that pyflakes checker parses the file from top to bottom, checking possible violations in sequence. So it locates this new local variable 'transport' definition, and checks thru the list of globals where there is an import with the same name. The problem occurs because transport import is not used in this file BEFORE the variable definition, while it's still used AFTER it, in other classes. I guess the check should be triggered only if the import in question is never used anywhere else in the file, no matter where the usage is located in regards to redefinition.\n\nThe code in question is in checker.py, addBinding():\n...\n if (isinstance(existing, Importation)\n and not existing.used\n and (not isinstance(value, Importation) or\n value.fullName == existing.fullName)\n and reportRedef\n and not self.differentForks(node, existing.source)):\n...",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8.1",
"owner": "ihar-hrachyshka",
"id": 1297161,
"duplicate_of": null,
"title": "F811 incorrectly triggered",
"comments": [
{
"owner": "florent.x",
"content": "Thank you for this report.\r\n\r\nThe patch is commited, and it will be in 0.8.1\r\nhttps://github.com/pyflakes/pyflakes/commit/ffe926c282bf78737f8c34dff111ccbdab6c837b",
"date_created": "2014-03-29T22:40:50Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1297161",
"date_created": "2014-03-25T09:41:46Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "I hit a bug while building a package in an Ubuntu Trusty chroot. One of the tests this package does is run pyflakes3 over its source code to ensure that its clean. A couple of the files have a non-ascii character in its comment block, e.g.:\n\nhttp://bazaar.launchpad.net/~gdebi-developers/gdebi/trunk/view/head:/GDebi/GDebiKDE.py\n\npyflakes opens its files with the default encoding, technically locale.getpreferredencoding() in Python 3. It does not specify an explicit encoding argument to its open() call.\n\nIn Python 3, the preferred encoding is taken from the locale settings, and in a chroot, the default local is POSIX, a.k.a. C, which causes locale.getpreferredencoding() to return ANSI_X3.4-1968, a.k.a. us-ascii. So it makes sense that the f.read() call tracebacks when it tries to decode the non-ascii character in the comment block using the ascii encoding. And this is exactly what happens.\n\nThis is despite the explicit encoding specification in the GDebiKDE.py file:\n\n# -*- coding: utf-8 -*-\n\nWe have a few options to work around this. We could force a UTF-8 encoding (e.g. us_en.UTF-8) in the build environment, which would force locale.getpreferredencoding() to 'utf-8'. Or we could skip the pyflakes3 test if the encoding doesn't have UTF-8.\n\nBut I think the right solution is for pyflakes to open the files with the proper explicit encoding. It should probably open the file in binary mode, read a few lines to see if there's a `coding` declaration, and then if so, re-open the file in text mode with the proper encoding. Alternatively, read the entire file in binary mode and explicitly decode it after grokking if there's any explicit encoding declared.\n\nI vaguely recall some related discussion about this in python-dev, but I could be misremembering that.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8.1",
"owner": "barry",
"id": 1299169,
"duplicate_of": null,
"title": "pyflakes3 ignores file encoding",
"comments": [
{
"owner": "florent.x",
"content": "I confirm the issue. I plan to fix it in the next release (the correct behaviour is already implemented in the pep8 tool).\r\n\r\nIn the meantime, another easy workaround is to install flake8.\r\n\r\n pip install -U flake8\r\n flake8 --select F your_project\r\n\r\nIt should do the right thing.",
"date_created": "2014-03-28T19:45:54Z"
},
{
"owner": "florent.x",
"content": "Steps to reproduce:\n\n$ LANG= python3 -m pyflakes /tmp/GDebiKDE.py \n/tmp/GDebiKDE.py: problem decoding source\n\nor\n\n$ LANG= pyflakes3 /tmp/GDebiKDE.py \n/tmp/GDebiKDE.py: problem decoding source",
"date_created": "2014-03-29T10:05:32Z"
},
{
"owner": "florent.x",
"content": "Fixed in trunk : only read bytes and delegate the decoding to the built-in compile(...)\r\n\r\nhttps://github.com/pyflakes/pyflakes/compare/7b85f86578...12b4d425e3",
"date_created": "2014-03-29T11:16:08Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1299169",
"date_created": "2014-03-28T19:17:50Z"
},
{
"status": "Confirmed",
"security_related": false,
"description": "Hi,\nAs far as I know, bug #872503 was meant to fix the issue of code using locals() not being recognized as using local variables and indeed the code\n\n# No warning\ndef test():\n a = 5\n return locals()\n\ndoes not raise any warnings, but I've noticed that using locals() in the context of a comprehension (except a list comprehension) will incorrectly make pyflakes assume that the locals are not being used.\n\nUsing code as an example,\n\n# No warning\ndef test():\n a = 5\n return [i for i in locals().values()]\n\ndoes not raise a warning but the following generator expression:\n\n# local variable 'a' is assigned to but never used\ndef test():\n a = 5\n return (i for i in locals().values())\n\nset comprehension:\n\n# local variable 'a' is assigned to but never used\ndef test():\n a = 5\n return {i for i in locals().values()}\n\nand dict comprehension:\n\n# local variable 'a' is assigned to but never used\ndef test():\n a = 5\n return {k: v for k, v in locals().items()}\n\nall raise the unused local variable warning, which is pretty inconsistent with the previous behavior.\n\nThis is not a hugely critical bug but it's annoying and it could imply some bugs in the comprehensions elsewhere. Thanks for reading.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "fawio",
"id": 1325966,
"duplicate_of": null,
"title": "inconsistent behavior with locals(), comprehensions and the unused local variable warning",
"comments": [],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1325966",
"date_created": "2014-06-03T12:44:44Z"
},
{
"status": "Confirmed",
"security_related": false,
"description": "Importing modules using fully-qualified paths appears to confuse pyflakes. Example #1:\n\n'''\n$ cat pyflakes-missed-unused-import.py\nimport somepackage.mod1\nimport somepackage.mod2\n\ndef do_something():\n somepackage.mod1.do_something()\n\n$ pyflakes pyflakes-missed-unused-import.py\n'''\n\nExpected output: an \"unused import\" warning about somepackage.mod2.\n\nActual output: no errors or warnings.\n\nExample #2:\n\n'''\n$ cat pyflakes-missed-missing-import.py\nimport somepackage.mod2\n\ndef do_something():\n somepackage.mod1.do_something()\n\n$ pyflakes pyflakes-missed-missing-import.py\n'''\n\nExpected output: a \"missing import\" error about somepackage.mod1 *and* an \"unused import\" warning about somepackage.mod2.\n\nActual output: no errors or warnings.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "gward",
"id": 1421013,
"duplicate_of": null,
"title": "Missing import warnings when importing fully-qualified modules",
"comments": [
{
"owner": "bitglue",
"content": "Indeed, this is an issue. Fixing it will require some substantial rework of Pyflakes' data model, because currently it doesn't know anything about attributes.",
"date_created": "2015-05-27T15:32:55Z"
}
],
"importance": "Low",
"lp_url": "https://bugs.launchpad.net/bugs/1421013",
"date_created": "2015-02-11T23:55:23Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "gettext module provides convenience function gettext.install() that injects a callable _ [single underscore] into builtins, so that internationalized code can be written like this:\n\nprint _(\"text\")\n\npyflakes reports every _ as undefined symbol.\n\nmoreover since it is injected in builtins, all imported modules have that symbol, thus the following works:\n\n# main.py\nimport gettext\nimport somemod\ngettext.install(...)\n\n#somemod.py\nprint _(\"text\")\n\nI'm not sure what sort of heuristic could be used to recognize _() when pyflake checks somemod.py.\nPerhaps a command line argument for extra builtins?",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7.2",
"owner": "dimaqq",
"id": 844592,
"duplicate_of": null,
"title": "Recognize _(\"text\") from gettext.install(...)",
"comments": [
{
"owner": "exarkun",
"content": "Instead of using the injected builtins feature of gettext, import the name. Then both pyflakes and human readers of the code will know what's going on.\r\n\r\n from gettext import gettext as _\r\n",
"date_created": "2011-09-08T11:45:39Z"
},
{
"owner": "dimaqq",
"content": "I'm not the expert on gettext, but it occurs to me there could be a subtle difference.\nAt least:\n\nIn [18]: __builtins__._ == gettext.gettext\nOut[18]: False\n\nIn [19]: __builtins__._\nOut[19]: <bound method GNUTranslations.gettext of <gettext.GNUTranslations instance at 0x1661d40>>\n\nIn [20]: gettext.gettext\nOut[20]: <function gettext at 0x13df938>\n\nI get the same translations from calling either function, and the proposed workaround works for me, but it's not always the case:\n\nFrom gettext doc:\ngettext.install(domain[, localedir[, unicode[, codeset[, names]]]])\nChanged in version 2.4: Added the codeset parameter.\nChanged in version 2.5: Added the names parameter.\n\nThus if someone uses extra parameters of install, result of _() and gettext.gettext() are different:\n\nIn [34]: gettext.install(APP, DIR, unicode=True)\n\nIn [36]: __builtins__._(\"test\")\nOut[36]: u'test'\n\nIn [37]: gettext.gettext(\"test\")\nOut[37]: 'test'\n\nHere difference is unicode vs str, that is _() includes unicode=True passed in install and gettext.gettext doesn't. I suppose similar differences could arise from codeset and names parameters to install.",
"date_created": "2011-09-08T13:00:58Z"
},
{
"owner": "exarkun",
"content": "The difference isn't really relevant to Pyflakes. The example I gave was meant to be a trivial example of how you can apply the solution. If you want a different gettext function to be bound to _, you can have a different gettext function bound to _. If you want unicode, use gettext.ugettext. If you want a particular domain, use the gettext.translation function to get an instance of something for the appropriate domain and then use that object's gettext method. etc.\n",
"date_created": "2011-09-08T22:16:40Z"
},
{
"owner": "kovid",
"content": "There are plenty of situations where large projects may decide to define project wide builtins, in order to save having to explicitly import a frequently used function in every single module. Please consider adding support for a user specified list of builtin names to ignore, either via a command line argument or an environment variable. ",
"date_created": "2011-12-14T10:20:20Z"
},
{
"owner": "kovid",
"content": "And for completeness, here's a wrapper script that uses the env var PYFLAKES_BUILTINS\n\n#!/usr/bin/env python\nimport os, __builtin__\n\nnames = os.environ.get('PYFLAKES_BUILTINS', '')\nnames = [x.strip() for x in names.split(',')]\nfor x in names:\n if not hasattr(__builtin__, x):\n setattr(__builtin__, x, True)\n\ndel names, os, __builtin__\n\nfrom pyflakes.scripts.pyflakes import main\nmain()\n",
"date_created": "2011-12-14T10:47:45Z"
},
{
"owner": "florent.x",
"content": "The version 0.6.1 added a parameter to the Checker constructor.\r\nSee issue 1107587: http://launchpad.net/bugs/1107587\r\n\r\nAn environment variable might be sensible for the command line usage.",
"date_created": "2013-01-29T17:07:00Z"
},
{
"owner": "florent.x",
"content": "Added environment variable PYFLAKES_BUILTINS as suggested. See NEWS.txt",
"date_created": "2013-04-24T12:20:16Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/844592",
"date_created": "2011-09-08T08:18:12Z"
},
{
"status": "New",
"security_related": false,
"description": "It would be nice if pyflakes could detect mistakes like this:\n\n try:\n oldtime = os.path.getmtime(fname)\n except OSError, IOError:\n oldtime = 0\n\nIn the general case, it's obviously difficult to tell whether this is an error or not; but I suspect that handling the exception variable name as a binding would give you a \"redefinition of Foo\" warning in most of the cases where a mistake has been made.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "mithrandi",
"id": 848455,
"duplicate_of": null,
"title": "Detect misuse of except",
"comments": [
{
"owner": "exarkun",
"content": "Sounds reasonable. At least it would be interesting to run such a check against existing codebases to see what comes up. :)\n",
"date_created": "2011-09-13T01:07:12Z"
},
{
"owner": "yatc18ks0-9a-ngeefk4xa",
"content": "Pyflakes 0.5.0 does generate the warning \"local variable 'IOError' is assigned to but never used\", so I believe this has been fixed.",
"date_created": "2011-10-22T14:51:32Z"
},
{
"owner": "mithrandi",
"content": "You only get the unused-local-variable warning if the try/except is in a function. However, it looks like pyflakes does not warn about shadowing builtins, which I thought it did, so my analysis in the description is probably wrong.",
"date_created": "2011-10-23T16:52:38Z"
},
{
"owner": "saperski",
"content": "There is no warning as of pyflakes 0.7.3, marking as fixed",
"date_created": "2013-09-05T23:52:05Z"
},
{
"owner": "saperski",
"content": "er, sorry, misunderstood... should be reopened again",
"date_created": "2013-09-05T23:55:04Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/848455",
"date_created": "2011-09-13T00:47:11Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "An assert of the form:\n\nassert (x, 'blahblah')\n\nis tautological, because a non-empty tuple always has a truth value of True. However, it is common to mistakenly construct an assert statement of this form when attempting to wrap it over multiple lines. Python 2.6+ already issues a SyntaxWarning about this, but it would be nice if Pyflakes detected it too.",
"tags": [],
"duplicates": [
1405778
],
"assignee": null,
"milestone": null,
"owner": "mithrandi",
"id": 848467,
"duplicate_of": null,
"title": "Detect tautological asserts",
"comments": [
{
"owner": "jayvdb",
"content": "Pull request for the specific problem raised here : https://github.com/pyflakes/pyflakes/pull/51\n\nI've also quickly hacked together detection of assertion of a static value. It is just a concept demo, in case anyone thinks it could be useful. It has cross-version issues, and could easily become more complete by adding more call names.\nhttps://github.com/jayvdb/pyflakes/commit/25234773b174f0eb34fca3cd2e734290d7ab3a5e\n",
"date_created": "2015-11-20T14:16:45Z"
},
{
"owner": "jayvdb",
"content": "Expanding on my post, I'm think only `assert False` and `assert True` should be the only static asserts permitted.\n\nWhile CPython is catching only the absolute worst type of assert, pyflakes can and IMO should report other problematic asserts.\n\nafaik, there is no Python parser that does anything sensible with alternative static asserts. So anything other than `assert False` and `assert True` is obfuscated code, either unintentional or intentional, and the cost/benefit weights heavily in favour of reporting it as if it is an unintentional code error. If it was intentional obfuscated code, the coder will be happy it causes an error.\n\nHowever, there could be use cases for embedding 'hidden' structured information in the assert ast, which are stripped in optimize mode. If that is a serious concern, I can package up my code as a flake8 plugin instead.",
"date_created": "2015-11-20T20:57:06Z"
},
{
"owner": "jwilk",
"content": "I used `assert 0` a few times, because that's less typing than `assert False`.\nDebian Code Search says I'm not the only one who's that lazy:\nhttps://codesearch.debian.net/search?q=%28%3Fm%29^\\s*assert\\s%2B0\\s*%28%2C|%24%29+filetype%3Apython\n\nWhat's the use case for `assert True`?\n\nIn general, I think assertions that are always true are probably mistakes; and assertions that are always false are probably intentional.",
"date_created": "2015-11-20T21:23:38Z"
},
{
"owner": "jayvdb",
"content": "Yea, I agree `assert 0` is self-evident enough that it shouldnt be an error.\n\ntbh, I can't think of a use case for `assert True`, and would happily report an error for it also. In its favour, `assert True` is at least quite clear about what it does and doesnt do.",
"date_created": "2015-11-20T21:52:31Z"
},
{
"owner": "bitglue",
"content": "https://github.com/pyflakes/pyflakes/pull/51",
"date_created": "2015-11-24T12:47:00Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/848467",
"date_created": "2011-09-13T01:03:01Z"
},
{
"status": "New",
"security_related": false,
"description": "These can take several forms:\n\n raise \"shouldn't happen\"\n raise 'Cannot determine type of callable: '+repr(callableObject)\n raise \"Can't read input parameters file : %s\" % options.input_file\n\nSome of these will be harder to detect than others.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "mithrandi",
"id": 848470,
"duplicate_of": null,
"title": "Warn about string exceptions",
"comments": [
{
"owner": "bitglue",
"content": "Pyflakes still supports python 2.5, where string exceptions are still allowed. Pyflakes has no way to know what the target python version is, so must take the conservative approach and assume the code might be targeted at python 2.5 and string exceptions are valid.\n\nFor code targeted at later versions, I suggest catching these errors in unit tests.",
"date_created": "2014-09-24T11:58:05Z"
},
{
"owner": "mithrandi",
"content": "Unfortunately the most common occurrences of string exceptions are in exceptional code paths that are never (and perhaps have never) been tested; but perhaps pyflakes is not the right tool for dealing with this problem (although, since pyflakes already has to deal with Python 2 vs Python 3, I could imagine support being added for more precise version targets).",
"date_created": "2014-09-24T12:12:05Z"
},
{
"owner": "florent.x",
"content": "According to the Python documentation:\n\n\u00ab Raising of strings as exceptions, as in the statement raise \"Error occurred\", is deprecated in Python 2.5 and will trigger a warning. The aim is to be able to remove the string-exception feature in a few releases. \u00bb\nhttps://docs.python.org/2.7/whatsnew/2.5.html#pep-352-exceptions-as-new-style-classes\n\nSo we could probably enforce this deprecation in a linter tool which supports Python 2.5.\n\nWith the examples posted in the initial requests, I think that this checker will be easy to implement for \"simple cases\" as a warning in the \"pep8.py\" tool, which does non-AST analysis of the code.",
"date_created": "2014-09-24T12:30:16Z"
},
{
"owner": "adiroiban",
"content": "+1 for fixing this in pep8.py",
"date_created": "2015-02-14T12:04:02Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/848470",
"date_created": "2011-09-13T01:05:39Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "See attached program for a trivial example of a common idiom: \n\n\"my special string %(with_a_variable)s\"%locals()\n\nI wouldn't expect pyflakes to know how to deal with an arbitrary dictionary in the right hand position, but the use of locals() means that certain variables are actually used!",
"tags": [
"formatting",
"string",
"substitution"
],
"duplicates": [
970637
],
"assignee": "florent.x",
"milestone": "0.6.1",
"owner": "ato2g-andrew",
"id": 872503,
"duplicate_of": null,
"title": "Pyflakes does not recognize locals() as a use",
"comments": [
{
"owner": "ato2g-andrew",
"content": "",
"date_created": "2011-10-11T20:44:08Z"
},
{
"owner": "exarkun",
"content": "Pyflakes can't be sure that `locals` refers to the builtin locals function which returns the locals of the scope it is used in. It could have been overridden with another object which behaves differently.\n\nPyflakes could probably track the name and determine if it has been overridden in a sensible way, but there's no way for it to tell if the intended use is for the name to be injected externally somehow.\n",
"date_created": "2011-10-11T21:10:47Z"
},
{
"owner": "ato2g-andrew",
"content": "Is Pyflakes goal to be correct every time it points out an error? Or to not miss errors within predefined categories?\n\nIn the current behavior, Pyflakes flags \"used\" variables as \"unused\". If the user replaces locals() with their own function definition they will not get an error. Assuming that locals() refers to the builtin will produce a \"sound\" error-finder as defined\nhttp://en.wikipedia.org/wiki/Soundness\n\n \n\n\n\n\n",
"date_created": "2011-10-11T21:43:32Z"
},
{
"owner": "exarkun",
"content": "Pyflakes' goal is to be useful. It does not try to fit into any particular formal mathematical framework.\n\nPersonally, I avoid the question of what pyflakes should do in this case by not using locals() to interpolate into strings. I don't find that this constrains my ability to write programs easily.\n\nI would say that injecting `locals` into a scope and expecting Pyflakes to behave correctly in that case is more unreasonable than expecting locals() interpolated into a string literal to mark the keys in the string literal as used locals. So, go ahead and submit a branch implementing this feature.",
"date_created": "2011-10-11T22:30:08Z"
},
{
"owner": "ielectric+",
"content": "I wrote a patch for this: https://github.com/kevinw/pyflakes/commit/947e988b3548d360e46ffc996eb4671fa875ca11",
"date_created": "2013-01-08T11:30:31Z"
},
{
"owner": "jaraco",
"content": "Thanks very much for this change. I also concur with the change.\n\nQuestion - should 'vars()' also be treated the same way as locals()?",
"date_created": "2014-07-16T12:00:33Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/872503",
"date_created": "2011-10-11T20:44:08Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "In the code:\n\ndef foo():\n x, y = 1, 2\n return 3\n\nx and y are not shown as being unused.",
"tags": [],
"duplicates": [
1276273
],
"assignee": null,
"milestone": "0.8.1",
"owner": "yatc18ks0-9a-ngeefk4xa",
"id": 879941,
"duplicate_of": null,
"title": "Unused variables aren't detected with destructuring assignment",
"comments": [
{
"owner": "glyph",
"content": "This is somewhat intentional. 'ignored, ignore, ignored, useful, ignored, ignored = some_dumb_tuple_that_should_have_been_an_object_with_attributes' is an unfortunately common idiom, given the way some Python APIs are designed.",
"date_created": "2012-06-22T21:20:33Z"
},
{
"owner": "exarkun",
"content": "I guess the point here is that *nothing* in the example is used. It is intentional that:\n\n x, y = 1, 2\n return x\n\ngenerates no warnings, but that seems to be a different case.",
"date_created": "2012-06-23T12:07:29Z"
},
{
"owner": "asmeurer",
"content": "As I pointed out in #1276273, the difference is that you are unpacking from a tuple literal. If you have\n\nfor root, dirs, files in os.walk(path):\n ...\n\nand never user \"dirs\", then there's no value in pyflakes telling you that, because os.walk gives you dirs whether you want to use it or not. \n\nBut if you write\n\na, b, c = 1, 2, 3\n\n(which is syntactically equivalent to a, b, c = (1, 2, 3))\n\nand you don't use b, then you might as well have written\n\na, c = 1, 3\n\nNobody made you unpack the second item but yourself. So PyFlakes should warn against it in this case. Of course, if someone write\n\nA = (1, 2, 3)\na, b, c = A\n\nthen there's no way it can know that you didn't mean to use every element of A. But for a tuple *literal* on the rhs of assignment, there's no valid reason to have unused entries, other than maybe you thought 1, 2, 3, was prettier than 1, 3 :)\n\n(and by the way, I disagree that these things should return some object with attributes. It would be even more painful to write\n\nfor walker in os.walk(path):\n root = walker.root\n dirs = walker.dirs\n files = walkter.files\n ...\n\nI contend that this is a very beautiful idiom, and item unpacking in general is a very useful feature of the language)",
"date_created": "2014-03-22T16:38:35Z"
},
{
"owner": "florent.x",
"content": "Thank you for clarifying.\r\n\r\nIt would be a good enhancement, indeed.",
"date_created": "2014-03-22T17:13:44Z"
},
{
"owner": "florent.x",
"content": "I've implemented the proposal by asmeurer.\r\n\r\nhttps://github.com/pyflakes/pyflakes/commit/4417b7730c3e42087d3adb56d13bd4756d05b0bc",
"date_created": "2014-03-30T02:39:58Z"
},
{
"owner": "asmeurer",
"content": "Cool. I always forget about star unpacking. I feel like that feature would get more people to move to Python 3 if they knew about it. ",
"date_created": "2014-04-01T01:15:08Z"
},
{
"owner": "ale-fener",
"content": "Hi all,\n\nI also came across this issue recently, with pyflakes 1.0.0, and I was very surprised that the following code does not generate any warnings:\n\ndef foo():\n a, b = some_function()\n return 1\n\nfollowing the comment #3, I didn't get why there is no value in knowing that any of the unpacked variables are unused, it seems to me that you can always write:\n\nfor root, _, files in os.walk(path):\n\ninstead of \n\nfor root, dirs, files in os.walk(path):\n\nif you are not going to use the 'dirs' variable, so I don't see why you might be forced to define a variable that you never use.\nThanks for the great tool anyway, I am really happy about it in general.\n\n",
"date_created": "2016-05-05T20:05:53Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/879941",
"date_created": "2011-10-22T14:54:32Z"
},
{
"status": "New",
"security_related": false,
"description": "In the code:\n\ndef decorator(func):\n return func\n\n\n@decorator\ndef defined_twice():\n pass\n\n\n@decorator\ndef defined_twice():\n pass\n\nPyflakes gives the error: twice.py:10: redefinition of function 'defined_twice' from line 5\n\nIt ought to be: twice.py:11: redefinition of function 'defined_twice' from line 6",
"tags": [],
"duplicates": [
1459257
],
"assignee": null,
"milestone": null,
"owner": "yatc18ks0-9a-ngeefk4xa",
"id": 879945,
"duplicate_of": null,
"title": "Incorrect line numbers for decorated functions",
"comments": [
{
"owner": "exarkun",
"content": "Why? The Python AST makes the decision that the first line of a function is the first decorator that applies to it. Pyflakes just propagates this information.\n",
"date_created": "2011-10-22T21:00:20Z"
},
{
"owner": "yatc18ks0-9a-ngeefk4xa",
"content": "The Python AST gives the line number where the function definition starts, which includes the decorator. However, the fault isn't on that line and the user cannot fix the issue by changing that line.\n\nGiven a FunctionDef node:\n\nnode.lineno # where the function definition starts\nnode.lineno + len(node.decorator_list) # where the function name is",
"date_created": "2011-10-25T10:40:11Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/879945",
"date_created": "2011-10-22T14:58:03Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "code:\n\n----------------------------------------\ntest = True\nif False:\n del(test)\nassert(test)\n----------------------------------------\n\npyflakes complains:\n[...].py:4: undefined name 'test'\n\n\ni guess this may be too hard for a static analysier, in which case, how about\n\n----------------------------------------\ntest = True\nif False:\n del(test)\nelse:\n assert(test)\n----------------------------------------\n\nwhere the usage is in a different else branch to the del\n\noutput:\n[...].py:5: undefined name 'test'",
"tags": [],
"duplicates": [
901235,
969919,
1212912
],
"assignee": "adiroiban",
"milestone": null,
"owner": "david-szotten",
"id": 885140,
"duplicate_of": null,
"title": "using del in if clause confuses pyflakes",
"comments": [
{
"owner": "exarkun",
"content": "You're welcome to give it a try.\r\n",
"date_created": "2011-11-02T13:03:51Z"
},
{
"owner": "saperski",
"content": "I have a code in https://github.com/kevinw/pyflakes/pull/28 \n(https://github.com/saper/pyflakes/commit/09c52fcfab742b4f67c9d21d18ae389c300b4ea6) to fix another bug https://bugs.launchpad.net/pyflakes/+bug/916264 but there is a code to detect if instructions are on different sides\nof \"if:\" and \"else:\" or \"try:/except:/else:\". I think this approach could be applied to this case as well.\n\nMore info about how it works here: \n\nhttps://code.launchpad.net/~dobey/divmod.org/pyflakes-less-redef/+merge/130183/comments/307409",
"date_created": "2013-01-06T23:14:48Z"
},
{
"owner": "florent.x",
"content": "bug #885140 marked as duplicate of this one",
"date_created": "2014-03-29T17:22:39Z"
},
{
"owner": "florent.x",
"content": "bug #1212912, actually",
"date_created": "2014-03-29T17:23:59Z"
},
{
"owner": "adiroiban",
"content": "Here is my attempt to fix this https://github.com/pyflakes/pyflakes/pull/12\n\nPlease take a look. Thanks!",
"date_created": "2015-02-14T11:18:53Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/885140",
"date_created": "2011-11-02T10:28:43Z"
},
{
"status": "Won't Fix",
"security_related": false,
"description": "It would be nice if pyflakes would provide an option for ignoring some warnings.\n\nFor example I have this code:\n\ntry:\n from setproctitle import setproctitle\nexcept ImportError:\n setproctitle = lambda t: None # pyflakes:ignore\n\nAnd pyflakes will complain that setproctitle is redefined.\nMaybe this is a bad code and this kind of things should be never ignored, but I just want to know if such a feature is wanted in pyflakes.\n\nHere is a workaround for implementing pyflakes:ignore\n\nclass PocketLintPyFlakesChecker(PyFlakesChecker):\n '''PocketLint checker for pyflakes.\n\n This is here to work around some of the pyflakes problems.\n\n Beside the AST tree, it is also initialized with the plain text content\n of the file.\n '''\n\n def __init__(self, tree, filename='(none)', text=None):\n self.text = text\n if self.text:\n self.text = self.text.split('\\n')\n super(PocketLintPyFlakesChecker, self).__init__(\n tree=tree, filename=filename)\n\n def report(self, messageClass, *args, **kwargs):\n text_lineno = args[0] - 1\n if self.text[text_lineno].find('pyflakes:ignore') >= 0:\n return\n self.messages.append(messageClass(self.filename, *args, **kwargs))",
"tags": [],
"duplicates": [
1287336
],
"assignee": null,
"milestone": null,
"owner": "adiroiban",
"id": 907742,
"duplicate_of": null,
"title": "Add support for ignoring some warnings",
"comments": [
{
"owner": "exarkun",
"content": "I'd rather fix the bugs in pyflakes that lead to spurious warnings.\n",
"date_created": "2011-12-22T12:33:09Z"
},
{
"owner": "bukzor",
"content": "We have some questionable-but-necessary code which uses globals().update(). The of course causes pyflakes to freak out about undefined variables. I'd like to be able to ignore those warnings, instead of ignoring pyflakes altogether.",
"date_created": "2012-03-20T01:43:41Z"
},
{
"owner": "esz-michel",
"content": "@sinzui: Can you link to the changeset? I am curious to see *how* this was implemented. Sorry if the link is already available somewhere, but I could noit find it :\\\n\nI would really like this feature as well, but more fine-grained as proposed. For example, pylint allows you to disable a specific error-code (see http://www.logilab.org/card/pylint_manual#messages-control). Or, the Java @SuppressWarnings annotation also allows you to ignore specific warnings.\n\nI find the proposed solution to simply ignore pyflakes altogether is a bit like a \"except Exception\": You might miss other errors ;)",
"date_created": "2012-04-29T09:34:26Z"
},
{
"owner": "sinzui",
"content": "Adi extended PyFlakesChecker to accept the raw text of the module being checked. The report() method looks of the line number of warning/error and in the text and looks for \"# pyflakes:ignore\". The report returns early if the comment is present.\n https://code.launchpad.net/~adiroiban/pocket-lint/907742/+merge/102882",
"date_created": "2012-04-30T14:25:55Z"
},
{
"owner": "adiroiban",
"content": "Hi,\n\nRight now, pyflakes messages do not have a ID for each message class. In pylint each message class has its own ID.\n\nI agree that this all or nothing filter can lead to other troubles. I will check to see if pyflakes developers would like to accept a patch to pyflakes to add IDs for each message class, and then we can improve the current pocketlint filter.",
"date_created": "2012-04-30T14:55:14Z"
},
{
"owner": "bukzor",
"content": "Alternative solution: use a pylintrc that is only roughly as picky as pyflakes.",
"date_created": "2012-05-21T23:16:32Z"
},
{
"owner": "glyph",
"content": "There's already a bug for automatically detecting the entirely detectable class of error in the example here, isn't there? It would be so much nicer to do that than to encourage users to drop these comment turds into their code.",
"date_created": "2012-06-19T04:53:04Z"
},
{
"owner": "exarkun",
"content": "More than one:\n\n https://bugs.launchpad.net/pyflakes/+bug/885140\n https://bugs.launchpad.net/pyflakes/+bug/800691\n https://bugs.launchpad.net/pyflakes/+bug/916264\n\nProbably others. Fixing these real problems would be a great win for all pyflakes users.\n\n",
"date_created": "2012-06-19T12:38:49Z"
},
{
"owner": "florent.x",
"content": "Issues 800691 and 916264 and many others were fixed with Pyflakes 0.6.1.\r\n\r\nIf you *really* want to use comments to disable some checks, try Flake8.\r\n\r\nBut the recommended path is to open an issue if it looks like a limitation of Pyflakes.",
"date_created": "2013-03-05T18:07:59Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/907742",
"date_created": "2011-12-22T12:17:45Z"
},
{
"status": "Won't Fix",
"security_related": false,
"description": "Currently pyflakes 0.5 does not detect unused function arguments.\n\nTo reproduce:\n\n$ echo \"def foo(bar): pass\" | pyflakes\n\nThis should warn that bar is never used, but it doesn't.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "jendrikseipp",
"id": 949563,
"duplicate_of": null,
"title": "Detect unused function parameters",
"comments": [
{
"owner": "glyph",
"content": "Actually, I don't think that pyflakes should do this. It's perfectly valid to have a function which accepts a bunch of parameters that it doesn't use, either because it's an implementation of an interface (maybe even a no-op implementation!) that doesn't require a parameter that another implementation might, or because it's accepting parameters that it may wish to use in the future.",
"date_created": "2012-03-08T06:06:22Z"
},
{
"owner": "jendrikseipp",
"content": "You're right, those are valid use-cases.\n",
"date_created": "2012-03-08T10:23:28Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/949563",
"date_created": "2012-03-08T01:06:26Z"
},
{
"status": "Triaged",
"security_related": false,
"description": "For example, code like this will break:\n\n >>> \"%(foo)\" % {\"foo\": \"bar\"}\n Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n ValueError: incomplete format\n\nIt'd be awesome if Pyflakes told me about that kind of issue.",
"tags": [],
"duplicates": [
1361849
],
"assignee": null,
"milestone": null,
"owner": "jkakar",
"id": 950369,
"duplicate_of": null,
"title": "Detect broken string templates that will raise ValueError when interpolated",
"comments": [
{
"owner": "jkakar",
"content": "I poked through the code and determined that implementing this kind of\ncheck will be a pretty big pain in the neck. We'd need to parse the\nstring to determine what kind of interpolation is required and then\nverify that with the arguments to be interpolated. ie, we'd need to\nimplement our own string interpolation engine. Ew.\n",
"date_created": "2012-03-08T23:21:10Z"
},
{
"owner": "exarkun",
"content": "A patch to implement this was sent to the mailing list, https://lists.launchpad.net/divmod-dev/msg00193.html",
"date_created": "2012-03-15T19:50:49Z"
},
{
"owner": "jwilk",
"content": "Implementing your own string interpolation engine may sound scary at first, but in fact it should be quite easy. For example, pylint has a template parser that is just ~60 lines of code:\nhttps://bitbucket.org/logilab/pylint/src/36355f1fe1fd/checkers/utils.py?at=default#cl-277\n\nI took a different approach in lintian4python, which resulted in even shorted code:\nhttps://bitbucket.org/jwilk/lintian4python/src/5e552f08d8f5/helpers/python/code-analysis?at=default#cl-292\n",
"date_created": "2013-12-09T13:35:27Z"
},
{
"owner": "asmeurer",
"content": "Too bad they're both GPL, as you otherwise could literally just reuse that code. ",
"date_created": "2013-12-09T18:09:56Z"
},
{
"owner": "jwilk",
"content": "The relevant part of lintian4python is under the same license as pyflakes.",
"date_created": "2013-12-10T07:11:36Z"
},
{
"owner": "asmeurer",
"content": "Rather than rewriting Python's string interpolation, would it be possible to just take the string and interpolate it with some dummy objects that have sufficient __int__, __float__, __str__, etc. defined on them, and see if any errors are raised (basically, reuse Python's own engine)?",
"date_created": "2015-05-28T18:29:31Z"
},
{
"owner": "jwilk",
"content": "Absolutely. That's what I did in lintian4python.",
"date_created": "2015-05-28T18:39:10Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/950369",
"date_created": "2012-03-08T22:38:18Z"
},
{
"status": "New",
"security_related": false,
"description": "Hello,\nas reported on Debian at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=653890:\n\n\"\"\"\nIt would be great if pyflakes could detect files that are python scripts\nbut are not named *.py. It would have to read the first two bytes of\neach file to check for scripts and then read the rest of the line to\ndetermine if it is a python script. It would need to process stuff like:\n\n#!/usr/bin/python\n#!/usr/local/bin/python\n#!/usr/bin/env python\n#!/usr/bin/python2.6\n#!/usr/bin/python3.2\n\"\"\"\n\nRegards,\nSandro",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "morph-debian",
"id": 970465,
"duplicate_of": null,
"title": "Please also check python scripts that are not named *.py",
"comments": [
{
"owner": "saperski",
"content": "I believe that pyflakes checks any file, regardless whatever the file name is. It even accepts input on stdin. Is this somehow debian specific?",
"date_created": "2013-01-06T23:17:02Z"
},
{
"owner": "morph-debian",
"content": "On Mon, Jan 7, 2013 at 12:17 AM, Marcin Cie\u015blak\n<email address hidden> wrote:\n> I believe that pyflakes checks any file, regardless whatever the file\n> name is. It even accepts input on stdin. Is this somehow debian\n> specific?\n\nhttp://bazaar.launchpad.net/~divmod-dev/pyflakes/trunk/view/head:/pyflakes/scripts/pyflakes.py#L91\n",
"date_created": "2013-01-08T10:46:38Z"
},
{
"owner": "icordasc",
"content": "Personally I'm -1 on this. Theoretically there could be a directory with hundreds of files with only a handful of python files (whether they bear the .py suffix or not). Having to check every file for All variations of `#!/usr/bin/python(version)` seems extraordinary and impractical. One reason not to do this is the following:\n\nLet's assume you have pyflakes installed under 2.6 (or even 2.5) while having files with a header that specifies python 3000 (any version you choose). It will fail upon compilation before it is even capable of doing any checks. That would be useless. On the other hand if you installed under python 3, there are object attributes that are no longer valid. I believe `iteritems` is a popular dictionary method that no longer exists on dictionaries in python 3.",
"date_created": "2013-02-02T19:00:41Z"
},
{
"owner": "myint",
"content": "Ian, I'm not sure how any of that follows from what Sandro is requesting. I think he is just asking for pyflake's \"os.walk()\" to look for files other than ones that end with \"*.py\". So instead of only checking \"filename.endswith('.py')\", also look for files by reading the first few bytes for the Unix shebang. And then check it against something like the regular expression \"^#!.*\\bpython[23]?\\b\\s*$\"",
"date_created": "2015-04-06T02:57:17Z"
},
{
"owner": "bitglue",
"content": "This sounds like a worthwhile feature, as long as it can be demonstrated that it does not significantly impact performance.",
"date_created": "2015-05-27T16:02:56Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/970465",
"date_created": "2012-03-31T23:34:02Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "pytest sues __tracebackhide__ to hide frames in tracebacks,\n\nwould be nice if that was honored",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7",
"owner": "ronny-pfannschmidt-deactivatedaccount",
"id": 1105525,
"duplicate_of": null,
"title": "ignore special locals of test frameworks",
"comments": [
{
"owner": "florent.x",
"content": "This seems fixed in 0.6.1 thanks to http://launchpad.net/bugs/1107587.",
"date_created": "2013-01-29T17:10:55Z"
},
{
"owner": "ronny-pfannschmidt-deactivatedaccount",
"content": "not at all\n\n__tracebackhide__ is a local one defines inside a function\n\nthe patch is about globals magically appearing",
"date_created": "2013-01-29T18:21:13Z"
},
{
"owner": "florent.x",
"content": "This use case is documented there http://pytest.org/latest/example/simple.html#writing-well-integrated-assertion-helpers",
"date_created": "2013-03-30T18:55:00Z"
},
{
"owner": "florent.x",
"content": "The merge-proposal is on GitHub, because auto-mirroring is broken since last Saturday.\r\n\r\nhttps://github.com/pyflakes/pyflakes/pull/5",
"date_created": "2013-04-02T21:22:57Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1105525",
"date_created": "2013-01-25T23:16:05Z"
},
{
"status": "Won't Fix",
"security_related": false,
"description": "execnet supports passing whole modules tor execution to a remote\n\nif its on a remote, then __name__ is '__channelexec__' and a global named channel can be used",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "ronny-pfannschmidt-deactivatedaccount",
"id": 1105526,
"duplicate_of": null,
"title": "support for execnet remote executable modules",
"comments": [
{
"owner": "florent.x",
"content": "The use case explained in the documentation:\nhttp://codespeak.net/execnet/basics.html#remote-exec-execute-source-code-remotely\n\nThis is covered (at least partially) with the optional argument \"builtins\" for the Checker constructor.",
"date_created": "2013-03-30T18:44:11Z"
},
{
"owner": "bitglue",
"content": "What might the solution to this look like? How would Pyflakes know that execnet is in use? Is there a way to accommodate this use case that does not compromise the more usual case of checking ordinary Python programs?",
"date_created": "2015-05-27T16:10:01Z"
},
{
"owner": "bitglue",
"content": "Closing this for lack of activity. This seems like a special case that would best be handled by constructing your own Checker object as florent.x describes.",
"date_created": "2015-11-17T15:26:30Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1105526",
"date_created": "2013-01-25T23:17:18Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "This commonly used pattern reports an UndefinedName with pyflakes 0.5\n\n try:\n socket_map\n except NameError:\n socket_map = {}",
"tags": [],
"duplicates": [],
"assignee": "florent.x",
"milestone": "0.7",
"owner": "florent.x",
"id": 1106930,
"duplicate_of": null,
"title": "with a NameError exception handler, an UndefinedName should not be raised",
"comments": [
{
"owner": "florent.x",
"content": "Ready for review.",
"date_created": "2013-03-30T16:18:29Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1106930",
"date_created": "2013-01-27T14:18:07Z"
},
{
"status": "New",
"security_related": false,
"description": "Given that pyflakes now has an API, it might be worthwhile to add documentation somewhere and since you're already hosting the source on GitHub, ReadTheDocs is an option.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "icordasc",
"id": 1113692,
"duplicate_of": null,
"title": "[Feature] Add hosted docs",
"comments": [
{
"owner": "florent.x",
"content": "It would be nice, indeed.\n\n\nThe legacy documentation has just an overview:\nhttp://divmod.readthedocs.org/en/latest/products/pyflakes.html\n\nWith a pending pull request:\nhttps://github.com/MostAwesomeDude/divmod-docs/pull/8",
"date_created": "2013-02-08T12:35:16Z"
},
{
"owner": "icordasc",
"content": "I'd be interested in helping set up docs on ReadTheDocs. I can send a pull request soon.",
"date_created": "2013-02-25T18:45:59Z"
},
{
"owner": "icordasc",
"content": "Heh. Sorry for lying. It wasn't intentional. I should have free time in the up-coming week or two.",
"date_created": "2013-05-11T17:32:43Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1113692",
"date_created": "2013-02-02T19:03:16Z"
},
{
"status": "New",
"security_related": false,
"description": "this would allow to do propper support for framework specific extra checks/bindings outside of pyflakes\n\nfor example, instead of the execnet support, i could pass in a mixin that overrides the check\nor instead of the ErrorReturn check, that could also be a mixin\n\nsame goes for supporting __tracebackhide__",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "ronny-pfannschmidt-deactivatedaccount",
"id": 1114708,
"duplicate_of": null,
"title": "allow to specify checker mixins",
"comments": [
{
"owner": "nejucomo",
"content": "I would like to argue against this kind of feature.\n\nPlugins would make it less clear what it means when a codebase does or does not pass pyflakes. Furthermore, plugins may not uphold the Design Principles. https://github.com/pyflakes/pyflakes#design-principles\n\nIf a codebase needs framework specific checks, why not run pyflakes *and* a different tool on that codebase? Finally, other tools like pylint are highly customizeable and already have plugin APIs, so if you really want one tool that performs many codebase-specific or user-specific tests, maybe that tool is more appropriate.\n",
"date_created": "2015-06-07T13:25:47Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1114708",
"date_created": "2013-02-03T23:59:53Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "A lot of Zope packages use the following style for their unit tests:\n\n import doctest\n\n from somepackage import something\n\n def doctest_something_does_it_right():\n \"\"\"\n\n >>> something('the ultimate answer')\n 42\n\n \"\"\"\n\n def test_suite():\n return doctest.DocTestSuite()\n\nSince pyflakes doesn't pay attention to doctests in docstrings, it tends to produce huge amount of false positives (\"unused name 'something') and it misses possible issues in the doctest code.\n\nThere's an old patch by Ignas Mikalaj\u016bnas that adds doctest support to pyflakes. I've been using it for a long time in my fork (lp:~mgedmin/pyflakes/pyflakes-mg). Florent Xicluna recently rebased it on top of the latest pyflakes in https://code.launchpad.net/~pyflakes-dev/pyflakes/0.6-doctest-support",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7",
"owner": "mgedmin",
"id": 1118173,
"duplicate_of": null,
"title": "Pay attention to doctests",
"comments": [
{
"owner": "florent.x",
"content": "The merge proposal was held back because it would have created conflict with the resolution of bug 1159514\n\nNow the merge proposal for adding column information is merged in trunk.\nhttps://code.launchpad.net/~pyflakes-dev/pyflakes/0.6-col-offset/+merge/156231\n\nThe branch related to the doctest-support needs update.",
"date_created": "2013-04-04T07:33:55Z"
},
{
"owner": "florent.x",
"content": "Merged for 0.7",
"date_created": "2013-04-16T17:51:57Z"
},
{
"owner": "mgedmin",
"content": "Thanks!",
"date_created": "2013-04-17T05:16:11Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1118173",
"date_created": "2013-02-07T09:37:37Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Please add a --version option so that I can check which version of Pyflakes I've got installed.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7",
"owner": "mgedmin",
"id": 1143978,
"duplicate_of": null,
"title": "Please add a --version option",
"comments": [
{
"owner": "gbrandl",
"content": "--help would also be nice.",
"date_created": "2013-03-29T11:11:58Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1143978",
"date_created": "2013-03-04T09:32:13Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "Consider this Python code:\n\nimport os\nimport os.path\nimport re\nre.search(\"a\", \"abd\")\n\n...for this code pyflakes will say:\n$ pyflakes .\n./aaa.py:2: 'os' imported but unused\n\nInstead of if the above I would like it to say:\n$ pyflakes .\n./aaa.py:1: 'os' imported but unused\n./aaa.py:2: 'os.path' imported but unused",
"tags": [],
"duplicates": [],
"assignee": "jayvdb",
"milestone": null,
"owner": "mnemo",
"id": 1153355,
"duplicate_of": null,
"title": "import os + import os.path both unused generates only a single slightly confusing warning",
"comments": [
{
"owner": "mnemo",
"content": "Bug found in 0.5.0-1ubuntu1",
"date_created": "2013-03-10T20:17:28Z"
},
{
"owner": "jayvdb",
"content": "fwiw, as of v1.2.0, the error message is less confusing as the name in the error message now matches what appears on the line of the source code:\n\n./aaa.py:2: 'os.path' imported but unused\n\nThis was done with\n\nhttps://github.com/pyflakes/pyflakes/commit/aec68a7847d8dbd1371242f42f9302103a68178f\n\nIt had a few bugs (lp:1560134 and lp:1578051), which have fixes yet to be released.\n\nIt still does not detect that both are unused, which turns out to be a spectacularly difficult problem to solve in pyflakes, but we're getting closer.",
"date_created": "2016-05-04T13:36:28Z"
},
{
"owner": "jayvdb",
"content": "Whoops, I set this to fix released, when it isnt. It should go back to New.",
"date_created": "2016-05-07T16:04:40Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1153355",
"date_created": "2013-03-10T20:17:14Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "In relation to this bug on Flake8: https://bitbucket.org/tarek/flake8/issue/90/column-missing-for-undefined-identifiers it would be useful if Pyflakes could report the column number by default or allow an option to be set through the API to enable reporting of the number.",
"tags": [],
"duplicates": [],
"assignee": "florent.x",
"milestone": "0.7",
"owner": "icordasc",
"id": 1159514,
"duplicate_of": null,
"title": "Support reporting the column number",
"comments": [
{
"owner": "florent.x",
"content": "maybe this feature was implemented in a fork of Pyflakes.",
"date_created": "2013-03-29T09:41:15Z"
},
{
"owner": "ronny-pfannschmidt-deactivatedaccount",
"content": "i recall this was implemented in kevins fork and basically amounts to pass the full position information to the reporting instead of just line numbers",
"date_created": "2013-03-29T10:46:00Z"
},
{
"owner": "florent.x",
"content": "I retrieved the code from Kevin's repository.\r\nPatch is attached.",
"date_created": "2013-03-30T16:17:22Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1159514",
"date_created": "2013-03-24T20:19:37Z"
},
{
"status": "New",
"security_related": false,
"description": "Pyflakes will generate a spurious \"imported but unused\" warning for the following code:\n\nimport selenium as se\nimport selenium.webdriver\n\nse.webdriver.Firefox(\"foo\")\n\nNote that Pyflakes will, correctly, *not* generate such a warning for the following:\n\nimport selenium\nimport selenium.webdriver\n\nse = selenium\n\nse.webdriver.Firefox(\"foo\")",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "bcs26",
"id": 1162031,
"duplicate_of": null,
"title": "\"import as\" can cause spurious \"imported but unused\" warnings",
"comments": [
{
"owner": "florent.x",
"content": "The \"imported but unused\" is not triggered on \"import ... as ...\".\r\nActually, it is triggered by the second import line, not the first one.\r\n\r\nI agree this is slightly confusing because of issue #1153355.\r\nBut it is not a bug.",
"date_created": "2013-03-29T21:29:32Z"
},
{
"owner": "bcs26",
"content": "Agreed that the warning targets the second \"import\". The warning itself, however, does seem to be caused by the presence of \"import as\". The following (effectively identical) code, for example, correctly does not trigger a warning:\n\n\nimport selenium\nimport selenium.webdriver\n\nselenium.webdriver.Firefox(\"foo\")\n\n\nNot sure I understand the comment about it not being a bug: an \"unused\" warning is generated, but both import lines are in fact essential (the code will raise an error if either is removed).",
"date_created": "2013-03-29T21:49:13Z"
},
{
"owner": "florent.x",
"content": "In the \"import as\" example, the name \"selenium\" is assigned in the global namespace but it is not used in the module. Only \"se\" is effectively used.\nIn the other example, the \"selenium\" name is assigned and is effectively used.\n\nThere are different ways to work around this and avoid putting an unused name in the globals. For example:\n\n from selenium import webdriver\n webdriver.Firefox(\"foo\")\n\n\nOr another example:\n\n import selenium as se\n __import__('selenium.webdriver')\n se.webdriver.Firefox(\"foo\")\n\n\nOr you keep the code as-is, and you just ignore this pyflakes message.",
"date_created": "2013-03-29T22:27:15Z"
},
{
"owner": "bcs26",
"content": "Ok, it honestly sounds like we just disagree on this.\n\nIf you'd like, I'm happy to call this a feature request: it would be helpful if pyflakes did not generate a warning for this code, since the only alternative is adding code solely to suppress the warning.\n\nThat said, while the *name* may be unused, the import operation is obviously essential. Using __import__(\"...\") to avoid introducing the name seems a bit silly, especially because pyflakes does not in general warn about unused top-level names---so, in this case, it is going out of its way to warn about reasonable code.\n\n(As a perhaps-interesting aside, using \"del selenium\" to remove the name generates a different warning.)",
"date_created": "2013-03-29T23:12:46Z"
},
{
"owner": "florent.x",
"content": "I keep the issue open, since you don't like the alternative examples which were proposed:\r\n\r\n import selenium\r\n import selenium.webdriver\r\n se = selenium\r\n se.webdriver.Firefox(\"foo\")\r\n\r\n(or)\r\n\r\n from selenium import webdriver\r\n webdriver.Firefox(\"foo\")\r\n\r\n\r\nFor the other remark, regarding the unassignment of globally imported objects, I opened bug 1162161 and attached a patch to it.",
"date_created": "2013-03-30T16:13:44Z"
},
{
"owner": "bcs26",
"content": "Sounds fair. Appreciated the discussion.\n\n\nOn Sat, Mar 30, 2013 at 9:13 AM, Florent <email address hidden> wrote:\n\n> I keep the issue open, since you don't like the alternative examples\n> which were proposed:\n>\n> import selenium\n> import selenium.webdriver\n> se = selenium\n> se.webdriver.Firefox(\"foo\")\n>\n> (or)\n>\n> from selenium import webdriver\n> webdriver.Firefox(\"foo\")\n>\n>\n> For the other remark, regarding the unassignment of globally imported\n> objects, I opened bug 1162161 and attached a patch to it.\n>\n> ** Changed in: pyflakes\n> Status: Incomplete => New\n>\n> --\n> You received this bug notification because you are subscribed to the bug\n> report.\n> https://bugs.launchpad.net/bugs/1162031\n>\n> Title:\n> \"import as\" can cause spurious \"imported but unused\" warnings\n>\n> To manage notifications about this bug go to:\n> https://bugs.launchpad.net/pyflakes/+bug/1162031/+subscriptions\n>\n",
"date_created": "2013-03-30T16:59:28Z"
},
{
"owner": "jayvdb",
"content": "It is possible, but not easy, for pyflakes to detect that `import selenium.webdriver` is altering `se`. But even if pyflakes detected this, IMO it should still emit an error for it. Instead of \"imported but unused\", it should report \"imported submodule a.b only used via c.b.\"\n\nIMO the two options provided in comment #5 are the correct \"flake free\" code, and IMO this is the most desirable:\n\n from selenium import webdriver\n webdriver.Firefox(\"foo\")\n\nIf a more descriptive prefix is desirable, that could be:\n\n from selenium import webdriver as selenium_webdriver\n selenium_webdriver.Firefox(\"foo\")\n",
"date_created": "2015-11-25T21:59:27Z"
},
{
"owner": "bcs26",
"content": "Both of those alternatives are totally reasonable... but at least IMO they don't feel super great.\n\nFor many larger packages (e.g. numpy) an \"import numpy as np\" style is extremely common, but you still need to import various submodules. If you apply the pattern above, you end up with \"import numpy.modulea as np_modulea\", \"import numpy.random.moduleb as np_random_moduleb\", etc. That obviously *works* but ends up creating two independent styles of usage. Not to mention the repetitive boilerplate in the actual imports.\n\nUltimately it feels like working around an implementation limitation on the linter side. Fine if that's what it takes, better if it's unnecessary!",
"date_created": "2015-11-26T20:36:05Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1162031",
"date_created": "2013-03-29T21:00:41Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "This case where we import a module for its side-effects gives a warning.\n\nimport fu\ndel fu\n\n\nor the one of bug 1162031\n\nimport selenium as se\nimport selenium.webdriver\ndel selenium\n\nse.webdriver.Firefox(\"foo\")\n\n\nNote that this case is covered in the test suite, so it might be intentional:\nhttp://bazaar.launchpad.net/~pyflakes-dev/pyflakes/master/view/72/pyflakes/test/test_imports.py#L23",
"tags": [],
"duplicates": [],
"assignee": "florent.x",
"milestone": "0.7",
"owner": "florent.x",
"id": 1162161,
"duplicate_of": null,
"title": "import fu; del fu complains about RedefinedWhileUnused",
"comments": [
{
"owner": "florent.x",
"content": "See merge-proposal here: https://github.com/pyflakes/pyflakes/pull/4\r\n\r\n(unfortunately the mirroring GitHub --> Pyflakes is broken)",
"date_created": "2013-04-02T21:26:15Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1162161",
"date_created": "2013-03-30T09:52:33Z"
},
{
"status": "New",
"security_related": false,
"description": "test.py:\n\nimport sys\n\nimport sys\n\ndef func():\n \"\"\"\n A docstring\n >>> import sys\n >>> sys.path\n \"\"\"\n\n return 1\n\nThe pyflakes output is\n\ntest.py:1: 'sys' imported but unused\ntest.py:6: redefinition of unused 'sys' from line 1\n\nThe line 6 \"redefinition of unused 'sys' from line 1\" is incorrect, because the doctest scope is separate from the module scope. \n\nI can't figure out how to reproduce it with a small file, but in this file: https://github.com/sympy/sympy/blob/master/sympy/physics/mechanics/functions.py, the output is\n\nsympy/physics/mechanics/functions.py:160: redefinition of unused 'diff' from line 27\nsympy/physics/mechanics/functions.py:200: redefinition of unused 'dynamicsymbols' from line 19\nsympy/physics/mechanics/functions.py:261: redefinition of unused 'dynamicsymbols' from line 19\nsympy/physics/mechanics/functions.py:458: redefinition of unused 'Point' from line 26\nsympy/physics/mechanics/functions.py:508: redefinition of unused 'Point' from line 26\n\nThat is, it complains about the imports in the doctests, but not the imports themselves (because they actually are used in the file).",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "asmeurer",
"id": 1178807,
"duplicate_of": null,
"title": "Add option to select scope for doctests",
"comments": [
{
"owner": "asmeurer",
"content": "I think it's because it's pushing a function scope for doctests, but really, it should be using a completely new module scope. Doctests are run like they a from-scratch Python interpreter. ",
"date_created": "2013-05-11T21:34:25Z"
},
{
"owner": "florent.x",
"content": "IIRC the imports at module level are available when running the doctests.\nThis could explain the warning.\n\nI don't use doctests enough to confirm it, though.",
"date_created": "2013-06-15T12:41:56Z"
},
{
"owner": "asmeurer",
"content": "Ah OK. So apparently Python's doctest module does work this way, but SymPy's doctester does not. Would it be possible to add an option to make doctests operate in their own module scope? This is IMHO the correct way to write doctests, because then users can just copy and paste the output and it will work (and that's why SymPy's doctester works this way). ",
"date_created": "2013-06-15T17:00:15Z"
},
{
"owner": "jayvdb",
"content": "This was fixed on Mar 30, 2014 by ffe926c282 (https://github.com/pyflakes/pyflakes/commit/ffe926c282).\n\nReproduced and confirmed fixed using https://github.com/sympy/sympy/commit/96dcc6a635\nSympy master has the same underlying problem, but the names are different.",
"date_created": "2015-11-17T05:51:27Z"
},
{
"owner": "asmeurer",
"content": "The real issue here was a feature request to add an option to use module scopes for doctests (see comment #3). ",
"date_created": "2015-11-17T17:11:14Z"
},
{
"owner": "jayvdb",
"content": "I'd like to explore whether it is necessary to run doctests as a top level scope.\n\nI've been working towards:\n1. processing the doctest scope so it can use the module scope (sloppy use of doctest, but very common)\n2. ensuring that the doctest scope does not report errors if it does not use the module scope (good use of doctest)\n3. reporting errors when the module scope relies on the doctest scope (very very bad use of doctest)\n\nThe doctest scope currently can re-import names also imported in the module scope, without error. I believe that is very very close to the request in #3, that doctest have their own 'module scope'.\ne.g. test_importInDoctestAndAfter : https://github.com/pyflakes/pyflakes/blob/master/pyflakes/test/test_doctests.py#L217\n\nNote that `test_importBeforeAndInDoctest` above `test_importInDoctestAndAfter` is a bit misleading, being marked as 'todo'. The code sample in that test does not report any errors, as it is effectively equivalent to `test_importInDoctestAndAfter`.\n\nIMO, broadly speaking, doctests shouldnt re-use names existing in the module scope, with imports being the obvious exception. If there is a case were re-importing in the doctest scope causes an error, IMO that needs to be fixed.\nAre there other situations where doctest re-using names from the module scope is preferable or even necessary?\n\nOn the structural problems mentioned in #1, a recent checkin (https://github.com/pyflakes/pyflakes/commit/93aa3c435505b8541b151c3e4b24c0ec4333f0bb) changed it so that a doctest is a module scope instead of a function scope. This is still not perfect, as the doctest scope should reside in the module scope, but it is currently deeply nested and resides with the object's scope where the docstring exists. That means currently it could inherit variables from any scope where the docstring resides; clearly a source of bugs, and this fix has been included in two of my pull requests. Maybe I should pull it out into a separate pull request with dedicated tests.\n\nThe other outstanding problem I am aware of is that a module level import which is only used in doctests is not reported as an error. I have a fix for that (https://github.com/jayvdb/pyflakes/commit/a8ccb1cef8ec005b07ea347823c4987d995d29c8), but it is waiting on a few other patches to be merged.\n\nThe unclear case that I am aware of is 'from x import foo' in module scope being shadowed by a 'from y import foo' in doctest scope. I suspect we'll need to declare that problem as unsolvable by pyflakes, as doctests should show recommended importation for clients, whereas the module level imports of the same names are sometimes different (more complex) due to internal mess/structure being hidden from the end-user.",
"date_created": "2015-11-22T00:22:28Z"
},
{
"owner": "jayvdb",
"content": "doctest scope level pull request: https://github.com/pyflakes/pyflakes/pull/52",
"date_created": "2015-11-22T01:49:24Z"
},
{
"owner": "asmeurer",
"content": "For my use-case, even imports should be required for doctests. Doctests should be considered for all intents and purposes to be completely independent modules. The idea is that a user should be able to run the code in a doctest in their own Python session and completely reproduce the output. ",
"date_created": "2015-11-22T08:22:40Z"
},
{
"owner": "mgedmin",
"content": "Consider this:\n\n def parse_color(color):\n \"\"\"Parse a color string and return (r, g, b) values from 0.0 to 1.0.\n\n Example:\n\n >>> parse_color('#fff')\n (1.0, 1.0, 1.0)\n\n \"\"\"\n\nAre you saying the name 'parse_color' shouldn't be automatically available in the doctest and instead there should be an explicit import? That feels to me like insisting on unnecessary boilerplate.\n\n(BTW Launchpad's issue tracker is *terribly inconvenient* would you PLEASE migrate to GitHub issues?)",
"date_created": "2015-11-22T09:21:00Z"
},
{
"owner": "jayvdb",
"content": "A stricter scope for doctest is easy to construct. The problem will be that we may need to create a few pyflakes options in order to accommodate various opinions of 'strict' ;-) pyflakes doesnt seem to like providing end-users with options -- only PYFLAKES_BUILTINS and PYFLAKES_DOCTEST exist. :/\n\nI expect most people would expect that a strict doctest scope would include only what is exported using __all__, if __all__ was defined (and sympy appears to do that systematically). That would typically eliminate imports, requiring re-imports in the doctest to access any other modules.\n\nThat would mean a doctest is not quite a completely independent module; instead each doctest essentially has an implicit \"from <current module> import *' at the beginning.\n\n@asmeurer, would that be 'close enough' for your needs?\n\nIf that still isnt good enough, then I think we need to design user selection of at least three alternatives:\n1. cpython doctest mode (default)\n2. __all__ exported names only\n3. empty scope\n\nThe obvious approach is some command line argument.\n\nIf the module includes a footer of `if __name__ == \"__main__\": import doctest; doctest.testmod()` , we could detect the list of desired globals by identifying `doctest.testmod(globs=[(name, globals()[name]) for name in __all__])` and `doctest.testmod(globs=None)` as a means of enabling option 2 or 3 respectively. The detection logic could also support extracting a custom list of valid names using a literal dict, i.e. doctest.testmod(globs={'a': 1, 'b': b}).\n\nA little more difficult approach, which probably needs assistance from pep8/flake8, is to export the \"inside doctest\" status to flake8 plugins, so that people wanting a stricter rules within doctests only can create flake8 plugins to achieve their own objectives.",
"date_created": "2015-11-22T12:03:30Z"
},
{
"owner": "jayvdb",
"content": "* would include only what is exported using __all__, if __all__ was defined, plus the name of the function/class the docstring is attached to if it isnt in __all__\n\n(and +1 for moving issues to github ;-)",
"date_created": "2015-11-22T12:24:18Z"
},
{
"owner": "asmeurer",
"content": "@mgedmin yes, for my use-case yes, we do use that kind of boilerplate (here are some examples http://docs.sympy.org/latest/modules/simplify/simplify.html). I agree that not everyone wants this, though, which is why I suggested making it an option. The different levels of scoping that @jayvdb suggests may also be useful, although I would be hesitant to implement them unless an actual doctest runner uses them. \n\n(and I'm also very +1 to moving to GitHub FWIW)",
"date_created": "2015-11-22T19:15:26Z"
},
{
"owner": "jayvdb",
"content": "I think all doctest runners supports custom globals. The following fails:\n\n`\n_m = 1\n\ndef doctest_stuff(self):\n '''\n >>> _m\n 1\n '''\n return 1\n\nif __name__ == \"__main__\":\n import doctest\n doctest.testmod(globs={})\n`\n\nThe problem is that pyflakes and other tools are assuming doctests are run with the default `doctest.testmod` arguments.\n\nI've raised a bug for the list of desired globals to be more easily specified in a way other tools can detect.\n\nhttp://bugs.python.org/issue25699",
"date_created": "2015-11-22T20:52:29Z"
},
{
"owner": "jayvdb",
"content": "It looks like http://bugs.python.org/issue25699 wont be accepted, so pyflakes will likely need to build this in the module.\nIn which case, we need to decide how to allow users to configure pyflakes. Only using env vars is not very user friendly.\n\n(and I'm also very +1 to moving to GitHub FWIW)",
"date_created": "2016-10-03T00:25:21Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1178807",
"date_created": "2013-05-10T19:58:57Z"
},
{
"status": "Invalid",
"security_related": false,
"description": "__init__.py files are full of unused import warnings, because all they are are imports. But this is one instance where it is correct to import something and not \"use\" it.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "asmeurer",
"id": 1178905,
"duplicate_of": null,
"title": "Don't report unused imports in __init__.py",
"comments": [
{
"owner": "asmeurer",
"content": "I see. It is trying to do this, but it only works if the module uses __all__. Isn't it more correct to just ignore all undefined names at the module level scope in an __init__.py file?",
"date_created": "2013-05-11T04:45:06Z"
},
{
"owner": "icordasc",
"content": "@asmeurer no it shouldn't. There are people who write actually classes and functions in __init__.py. Those people are expecting these errors. There is probably no really good way to ignore some and not others.",
"date_created": "2013-05-11T13:26:22Z"
},
{
"owner": "asmeurer",
"content": "But even if you do that, all imported names are going to be used for import purposes. And there will be so many false positives that no one will ever notice a mistake from pyflakes anyway. ",
"date_created": "2013-05-11T16:58:22Z"
},
{
"owner": "icordasc",
"content": "With the same exact example above you can not be certain of that. I could write something that imports a module, refactor and completely forget to remove the import were I to not have pyflakes reporting for it. Why should pyflakes just assume that I'm leaving it there for someone else to import into their library?\n\nIn short, the best way to really do this is to use __all__. It's the only reliable way to avoid the unused import warnings since it clearly shows the intent of the module author. If you're using submodules instead and don't wish to have to do:\n\n from sub_module import (exported, names)\n # etc.\n\n __all__ = [exported, names, ...]\n\nThen do\n\n import sub_module1\n import sub_module2\n # etc.\n import sub_modulen\n\n __all__ = []\n\n for i in range(1, n + 1):\n __all__.extend(globals()['sub_module%d' % i].__all__)\n\nObviously that's a bit contrived, but you get the point. You can be guaranteed it will execute only once and it won't cause you other troubles with pyflakes.",
"date_created": "2013-05-11T17:15:12Z"
},
{
"owner": "asmeurer",
"content": "> Why should pyflakes just assume that I'm leaving it there for someone else to import into their library?\n\nBecause you're writing it in __init__.py. That's exactly what that file is for. Besides, writing extensive code in __init__.py is (IMO) bad style, and you shouldn't be surprised if pyflakes misses errors because of it. \n\nBy the way, what is the general stance for pyflakes aboud false positives vs. false negatives?",
"date_created": "2013-05-11T17:25:10Z"
},
{
"owner": "icordasc",
"content": "It's bad style in my opinion too, but is far more common than I like.\n\nYou're still going to have push back from plenty of people though that there's no checking on __init__.py and they should feel surprised that pyflakes missed errors in it.",
"date_created": "2013-05-11T17:37:54Z"
},
{
"owner": "florent.x",
"content": "IMHO, the \"__all__\" declaration is the only safe way to prevent this warning. I agree with Ian.\n\nhttp://docs.python.org/3.4/tutorial/modules.html#importing-from-a-package\n\nIf you need more flexibility, Flake8 \"# noqa\" should help.",
"date_created": "2013-06-15T12:38:18Z"
},
{
"owner": "asmeurer",
"content": "Today's update to PEP 8 says, \"Wildcard imports (from <module> import *) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools. There is one defensible use case for a wildcard import, which is to republish an internal interface as part of a public API (for example, overwriting a pure Python implementation of an interface with the definitions from an optional accelerator module and exactly which definitions will be overwritten isn't known in advance).\n\n\"When republishing names this way, the guidelines below regarding public and internal interfaces still apply.\"\n\nIs that argument enough to change this behavior?",
"date_created": "2013-08-01T15:55:36Z"
},
{
"owner": "exarkun",
"content": "No. Be explicit about the names you want to export. Define an `__all__` on your package.\n",
"date_created": "2013-11-03T13:47:45Z"
},
{
"owner": "asmeurer",
"content": "It seems like __all__ is unnecessary complexity for most packages, and may make the import time unnecessarily slower (I haven't timed it, though, so I could be wrong about the speed). ",
"date_created": "2013-11-03T20:19:35Z"
},
{
"owner": "bjodah",
"content": "I completely agree with @asmeurer on this. It has always been and still is my biggest concern with pyflakes.",
"date_created": "2015-11-03T13:54:30Z"
},
{
"owner": "pierre-sassoulas",
"content": "Maybe flake could give a different more explicit warning message and not F401, when there is unused import in an __init__ file. Something like \"x imported but unused, declare with __all__ if you want to explicitly export this name\".",
"date_created": "2016-10-27T14:57:24Z"
},
{
"owner": "alevis",
"content": "Still an inconvenience. ",
"date_created": "2017-01-29T01:05:21Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1178905",
"date_created": "2013-05-11T04:27:16Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "The dependency on unittest2 causes problems when trying to run the tests for Python 3 at package build time in Debian and Ubuntu. We don't have a python3-unittest2 package available. IIUC, upstream unittest2 doesn't support Python 3 anyway; that's available in a separate package called: https://pypi.python.org/pypi/unittest2py3k but that's not available in Debian.\n\nIs the dependency on unittest2py3k really necessary for Python 3? Is it possible to conditionally import unittest2 only when running in Python 2?",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.7.3",
"owner": "barry",
"id": 1183953,
"duplicate_of": null,
"title": "Tests depend on unittest2",
"comments": [
{
"owner": "barry",
"content": "Oh, and related: LP: #1097061\n\n(but I agree with the above that a dependency on Twisted for testing is suboptimal)\n",
"date_created": "2013-05-24T18:01:53Z"
},
{
"owner": "florent.x",
"content": "Well, I have nothing against removing this dependency, but I fail to integrate \"unittest\" from Python 3.3 and \"setuptools\" ...\n\nThis is the problematic line in \"setup.py\":\n\n 'test_suite': 'unittest2.collector.collector'\n\nAny idea ?\nThanks.",
"date_created": "2013-06-15T12:29:25Z"
},
{
"owner": "barry",
"content": "On Jun 15, 2013, at 12:29 PM, Florent wrote:\n\n>Well, I have nothing against removing this dependency, but I fail to\n>integrate \"unittest\" from Python 3.3 and \"setuptools\" ...\n>\n>This is the problematic line in \"setup.py\":\n>\n> 'test_suite': 'unittest2.collector.collector'\n>\n>Any idea ?\n\nSince all your tests live in the pyflakes.test subpackage, it should be enough\nto just do this:\n\ntry:\n from setuptools import setup\nexcept ImportError:\n from distutils.core import setup\n extra = {'scripts': [\"bin/pyflakes\"]}\nelse:\n if sys.version_info < (3,):\n extra = {'tests_require': ['unittest2'],\n 'test_suite': 'unittest2.collector'}\n else:\n ## extra = {'tests_require': ['unittest2py3k'],\n ## 'test_suite': 'unittest2.collector.collector'}\n extra = {'test_suite': 'pyflakes.test'}\n extra['entry_points'] = {\n 'console_scripts': ['pyflakes = pyflakes.api:main'],\n }\n\nAfter I changed all the imports from 'unittest2' to 'unittest', it all just\nworked:\n\n...\n----------------------------------------------------------------------\nRan 544 tests in 0.467s\n\nOK (skipped=33)\n",
"date_created": "2013-06-18T21:48:18Z"
},
{
"owner": "florent.x",
"content": "Thank you for this hint, Barry.\r\n\r\nI dropped the test dependency for Python >= 2.7 (in revision 101).",
"date_created": "2013-06-18T23:00:22Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1183953",
"date_created": "2013-05-24T18:01:12Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "running with pypy\n\n----------------------------------------------------------------------\nRan 544 tests in 2.363s\n\nFAILED (failures=11, skipped=33)\n\nDo we care?",
"tags": [
"tests"
],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "johneed",
"id": 1186139,
"duplicate_of": null,
"title": "pypy support?",
"comments": [
{
"owner": "johneed",
"content": "",
"date_created": "2013-05-31T06:25:35Z"
},
{
"owner": "florent.x",
"content": "Contribution is welcome on the topic of Pypy support.",
"date_created": "2013-06-15T12:19:28Z"
},
{
"owner": "jayvdb",
"content": "Pull request submitted: https://github.com/pyflakes/pyflakes/pull/50",
"date_created": "2015-11-19T08:01:54Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1186139",
"date_created": "2013-05-31T06:25:35Z"
},
{
"status": "Invalid",
"security_related": false,
"description": "A commons source of silly bugs is to call some method or function that doesn't need parameters, say, data_update(), without the empty parens, so that, e.g,\nprint(data_update)\n<method data.update at 0x7f4c315e1830>\nIt would be nice to have a t least the option to raise a warning when a method is called without parens, since as far as I know referencing the memory address of a method is not done often.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": null,
"owner": "lorenzo233",
"id": 1188565,
"duplicate_of": null,
"title": "Warning for methods called without parens?",
"comments": [
{
"owner": "asmeurer",
"content": "I'm not a pyflakes developer, but this will probably be rejected. Pyflakes is only for actual logical errors. Warnings like this fit projects like pylint better. \n\nAnd anyway, I disagree that no one ever uses functions without calling them. I pass closures around all the time. ",
"date_created": "2013-06-07T15:00:01Z"
},
{
"owner": "florent.x",
"content": "I agree that it does not match with Pyflakes tool, because it will give plenty of False positive.\r\n\r\nIf you need this feature, you should probably write a plugin for Flake8 instead.",
"date_created": "2013-06-15T12:16:35Z"
},
{
"owner": "exarkun",
"content": "This is what unit tests are for.\n",
"date_created": "2013-11-03T13:48:34Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1188565",
"date_created": "2013-06-07T10:48:08Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "The following example:\n\n```\ndef test(a, b):\n yield a\n return b\n```\n\npasses pyflakes, even though it is invalid syntax in Python 2.\n\nMigrated from here: https://bitbucket.org/tarek/flake8/issue/112/return-with-argument-inside-generator-not",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8",
"owner": "attilaolah",
"id": 1198132,
"duplicate_of": null,
"title": "Return with argument inside generator",
"comments": [
{
"owner": "attilaolah",
"content": "Attached a [pull request](https://bitbucket.org/tarek/flake8/issue/112/return-with-argument-inside-generator-not).",
"date_created": "2013-07-05T12:11:15Z"
},
{
"owner": "florent.x",
"content": "This is merged in trunk\r\nhttps://github.com/pyflakes/pyflakes/pull/11",
"date_created": "2014-03-22T14:11:53Z"
}
],
"importance": "Wishlist",
"lp_url": "https://bugs.launchpad.net/bugs/1198132",
"date_created": "2013-07-05T10:32:52Z"
},
{
"status": "Fix Released",
"security_related": false,
"description": "It would be really great to be able to ignore/filter doctest errors. E.g.::\n\n---\n\ndef something(f):\n \"\"\"\n >>> a + 1\n \"\"\"\n return f + 1\n\n\n---\n\nAnd you could choose to ignore the error about 'a' not being defined.",
"tags": [],
"duplicates": [],
"assignee": null,
"milestone": "0.8",
"owner": "jtratner",
"id": 1223150,
"duplicate_of": null,
"title": "Disable doctest checking unless an option is passed",
"comments": [
{
"owner": "exarkun",
"content": "I'd love for this regression to be fixed. It is dumping a lot of spurious warnings into pyflakes output for my project.",
"date_created": "2013-10-30T22:46:48Z"
},
{
"owner": "jtratner",
"content": "It turns out there's an environment variable you can set PYFLAKES_NODOCTEST that magically turns this off, would be nice if it were documented.",
"date_created": "2013-10-30T22:58:40Z"
},
{
"owner": "glyph",
"content": "\"Don't check doctests\" should really be the default behavior. Checking doctests by default in this manner is a regression, since it causes false positives.\n\nIf you have doctests and you want them checked, you know it, and you can easily pass an additional option. Many examples in code that use a >>> prefix are not doctests and should not be treated as such.\n\n(Honestly I think it's weird that this feature got added at all: Pyflakes' whole raison d'\u00eatre is to be simple and fast and err on the side of checking only things that are clearly invalid; if you want to lint every possible insane thing, pychecker and pylint are already endlessly configurable to do things like this, aren't they?)",
"date_created": "2013-10-30T23:25:16Z"
},
{
"owner": "glyph",
"content": "Changed the subject since apparently PYFLAKES_NODOCTEST is already an option, but I'd still like it if it were the default.",
"date_created": "2013-10-30T23:26:48Z"
},
{
"owner": "mgedmin",
"content": "To satisfy your curiosity: there are large codebases out there (mostly from the Zope project) that have large numbers of doctests, and not checking them causes large numbers of false positives for