summaryrefslogtreecommitdiff
path: root/pyflakes/checker.py
Commit message (Collapse)AuthorAgeFilesLines
* Support Python 3.7Steven Myint2017-05-291-1/+13
| | | | This fixes #271.
* Process function scope variable annotations (#88)Jakub Stasiak2017-01-221-8/+1
| | | | | | | | | | | | | | | | | | Even though variable annotations in function scope aren't evaluated at runtime it's still useful for static analysis tools to process them and catch some issues (and not report some things that aren't issues). Let's take the following code: from typing import Any def fun(): a: Any Previously pyflakes would report Any to be unused: test.py:1: 'typing.Any' imported but unused With this patch it's no longer the case.
* Enable support for PEP 526 annotated assignments (#84)Łukasz Langa2017-01-061-0/+18
| | | | | | Without this change, code with annotated assignments is crashing pyflakes with an attribute error (`object has no attribute 'ANNASSIGN'`). Test plan: new tests introduced conforming to behavior described in the PEP.
* Fix format string checking (#80)Jared Garst2016-09-081-1/+1
| | | | format strings (PEP 498) defines a new AST node, JOINEDSTR which contains a list of string expressions.
* Point URLs to PyCQA (#79)Ville Skyttä2016-09-021-1/+1
|
* Fix typos (#77)Jakub Wilk2016-07-271-2/+2
|
* Check for duplicate dictionary keys (#72)geokala2016-07-251-1/+100
|
* Fix "continue" and "break" checks ignoring py3.5's "async for" loop (#71)Yann Kaiser2016-07-041-1/+7
|
* Fix TypeError when processing relative imports (#61)John Vandenberg2016-05-121-6/+17
| | | | | | | | | | | | | | Fixes lp:1560134 aec68a784 added module names to error messages, however it caused a TypeError for relative imports that do not specify a module such as: from . import x This fixes the TypeError, and also adds the necessary leading dots for relative import error messages. Add tests for various types of relative imports.
* Avoid traceback when exception is del-ed in except (#67)Phil Frost2016-05-061-1/+7
| | | | | | | | | | | | | Fixes a regression introduced by 2a698f87c02a43d4489e30481e9def14ed4b4431. This would fail with a KeyError: try: pass except Exception as e: del e Fixes lp:1578903
* Suppress RedefinedWhileUnused for submodule import (#62)John Vandenberg2016-05-051-4/+18
| | | | | | | | | | Fixes lp:1578051 aec68a7 added module names to error messages, which included a new class SubmoduleImportation to handle the special case of submodule imports. It correctly handled the case of a submodule import occurring after the root module was imported, but didnt handle the opposite case of the submodule import occurring before the root module was imported.
* Warn against reusing exception names after the except: block on Python 3Łukasz Langa2016-04-121-5/+26
|
* Importation classes with imported name and aliasJohn Vandenberg2016-03-151-10/+88
| | | | | | | | | | | | | | | | In order to solve many corner cases related to imports, more information is needed about each import. This change creates two new classes: - SubmoduleImportation - ImportationFrom And adds an optional parameter full_name to the super class Importation. Functionally, this change only improves existing error messages to report the full imported name where previously an error would include only the import alias.
* Handle matrix-multiplication operator ("@")matmulSteven Myint2015-12-211-1/+2
| | | | | | https://docs.python.org/3.6/whatsnew/3.5.html#pep-465-a-dedicated-infix-operator-for-matrix-multiplication This fixes https://bugs.launchpad.net/pyflakes/+bug/1523163.
* Check feature names imported from futureJohn Vandenberg2015-11-251-0/+4
| | | | | As '*' does not appear in __future__.all_feature_names, this also reports an error on : from __future__ import *
* Allow __future__ in doctestJohn Vandenberg2015-11-251-4/+30
| | | | | Replaces plain attribute Checker.futuresAllowed with a property that supports __future__ in both module and doctest.
* Process doctest scope directly under the module scopeJohn Vandenberg2015-11-251-14/+23
| | | | | | | | | | | | | | | | | | | | | | | | Explicitly place the doctest directly under the module scope, instead of processing it while within the scope where the docstring was encountered. Also do not process doctest which are not processed by default according to the doctest documentation. The primary benefit of moving the doctest scope directly under the module scope is that it may be efficiently identified, as it may only appear second in the stack. However it also ensures that the doctest scope can not access names in scopes between the module scope and the object where the docstring was encountered. As it was, class scope rules prevented the doctest scope from accessing names in a class scope, however the doctest scope was able to access names in an outer function, if the doctest appeared in a nested function. Note that there was no real bug there, as the doctest module does not process doctest in nested functions (Python issue #1650090), so doctest appearing in nested functions are informational only. pyflakes previously inspected doctest in nested functions, and now these are ignored.
* Report each usage of star importsJohn Vandenberg2015-11-241-9/+50
| | | | Also detect unused star imports.
* Report assert using tupleJohn Vandenberg2015-11-241-1/+6
| | | | | | This is a SyntaxWarning on Python 2.6+ Resolves lp:848467
* Fix undefined name in generators in classJohn Vandenberg2015-11-201-14/+13
| | | | | 8c8a27b8 provided a partial solution for generators in the class scope, however it did not account for generators enclosing other generators.
* Fix PyPyJohn Vandenberg2015-11-201-2/+15
|
* Python 3 only allows import * at module levelJohn Vandenberg2015-11-191-0/+5
|
* Import in Class is a public memberJohn Vandenberg2015-11-151-0/+4
| | | | | | An import in a class is a member of the class, and may be used outside the class scope, so it can not be marked as unused.
* Check for non-ast SyntaxErrorsnonastAaron Meurer2015-11-131-4/+61
| | | | | | | | | | | This includes return and yield outside of a function and break and continue outside of a loop. Fixes lp 1293654. The problem is that these SyntaxErrors are not encoded in the ast grammar, so they are not detected when just compiling to ast. You must compile down to bytecode to catch them. The advantage here is that we can still check for other kinds of errors in this case, because the ast is still valid.
* Add DoctestScopeJohn Vandenberg2015-11-121-5/+16
| | | | | | | Fix bug in 03ffc76 caused by determining the doctest global scope level based on whether parsing doctests was enabled. Also do not parse docstrings within doctests.
* Fix global removing all UndefinedNameJohn Vandenberg2015-11-121-2/+4
| | | | | | | 03ffc763 introduced better global support, however a logic error caused it to remove any previously detected UndefinedName whenever a global was encountered.
* PEP 498 f-strings supportJohn Vandenberg2015-11-081-1/+1
| | | | | PEP 498 f-strings cause pyflakes to crash with AttributeError: 'Checker' object has no attribute 'FORMATTEDVALUE'
* Fix documentation of Binding.usedJohn Vandenberg2015-11-031-2/+2
| | | | | ef4da24 changed the Binding.used tuple from (scope, line number) to (scope, node). This updates the docstring to reflect this change.
* Merge pull request #27 from ryneeverett/used-global-importPhil Frost2015-08-281-3/+4
|\ | | | | Don't report UnusedImport when binding global name
| * Don't report UnusedImport when binding global nameryneeverett2015-08-141-3/+4
| | | | | | | | | | When an import binds to a name declared global by the "global" statment, don't report it as unused.
* | Support Python 3.5 async/await statements for Pyflakes.Igor Davydenko2015-08-261-3/+6
|/
* Roll back changes, add comment, and skip the test.ryneeverett2015-08-141-4/+4
|
* Don't mark shadowing variable as 'used'.ryneeverett2015-08-131-3/+4
| | | | | | Shadowing a used variable should still potentially raise an UnusedVariable warning. Alter tests' expected results to agree with this premise.
* Fix TypeError bug.ryneeverett2015-06-161-1/+1
| | | | The Binding.used property must be a tuple (unless it's False).
* Improve 'global' statement support.ryneeverett2015-04-271-2/+24
| | | | | Add declared globals to each scope in the scope stack to avoid erroneous UndefinedName errors when they are loaded.
* Properly support list comprehensions in Python 3Steven Myint2015-03-201-1/+3
| | | | | | List comprehensions have their own scope in Python 3. https://docs.python.org/3/reference/expressions.html#displays-for-lists-sets-and-dictionaries
* Merge pull request #12 from chevah/885140-del-if-whilePhil Frost2015-02-141-0/+18
|\ | | | | [#885140] Update del handling in if and while statements.
| * Update after bitglue's review.Adi Roiban2015-02-141-22/+2
| |
| * Update del handling in if and while statements.Adi Roiban2015-02-141-0/+38
| |
* | Add an error for return outside of function.Adi Roiban2015-02-141-0/+4
|/
* Fix for lp/bug/1324942Charles-Francois Natali2014-07-231-1/+1
|
* Avoid crash on "return 2"Steven Myint2014-04-261-1/+5
|
* Release version 0.8.10.8.1Florent Xicluna2014-03-301-0/+2
|
* Refactor and (arguably) simplify.Florent Xicluna2014-03-301-53/+40
|
* Remove commentFlorent Xicluna2014-03-301-2/+0
|
* Do not bind the function in the current scope, until its arguments are ↵Florent Xicluna2014-03-301-1/+1
| | | | handled; fixes lp:1270952
* RefactoringFlorent Xicluna2014-03-301-7/+7
|
* Report undefined name for literal tuple unpacking; fixes lp:879941Florent Xicluna2014-03-301-8/+21
|
* Restore correct behaviour of __future__ importsFlorent Xicluna2014-03-301-2/+2
|
* Be consistent, it's named node_class in the moduleFlorent Xicluna2014-03-301-4/+4
|