summaryrefslogtreecommitdiff
path: root/pylint/checkers/variables.py
Commit message (Collapse)AuthorAgeFilesLines
* Check if node is in list comprehension in function defaultsBryce Guinta2018-03-031-2/+6
| | | | | | | List comprehensions in python 2 do not have scope. If the local scope is skipped, then generated variables values will raise a false-positive. Close #1897
* Fix false positive undefined-variable for lambda arguments in classesBryce Guinta2018-03-021-2/+11
| | | | Close #1824
* Exempt `__doc__` from triggering a `redefined-builtin`Claudiu Popa2018-03-011-1/+1
| | | | | `__doc__` can be used to specify a docstring for a module without passing it as a first-statement string.
* Backport of PR #1757hippo912018-01-041-38/+115
|
* Regenerate copyright noticesClaudiu Popa2017-12-151-3/+19
|
* past.builtins import don't trigger redefined-builtin. Close #1764Claudiu Popa2017-12-121-1/+1
|
* Adding a check for ``inconsistent-return-statements`` inside function or ↵hippo912017-09-261-1/+3
| | | | | methods. (#1641) Close #1267
* Add a couple of Uninferable filters where we weren't using anyClaudiu Popa2017-08-151-2/+2
|
* Don't mark dynamically added __class__ as unused variable. Close #1609Claudiu Popa2017-08-091-0/+7
|
* Fixed grammatical mistake in error message. (#1517)Dan Garrette2017-06-071-1/+1
|
* Handle keyword-only args annotation variables. Close #1168Claudiu Popa2017-04-121-0/+1
|
* Spelling fixes (#1397)Ville Skyttä2017-04-021-1/+1
|
* Add ignored_ and unused_ to unused-* inspections (#1357)Nathaniel Manista2017-03-071-2/+2
|
* Objects with the same name as inner attributes are not marked as unused any ↵Derek Gustafson2017-01-211-5/+13
| | | | | | | | | | | longer. If a name of an external object was being redefined in another scope, as in the following example, then pylint would have complained about the external object not being used any longer. from a import b # this gets an unused variable warning. class A: b = b[0]
* Fix not-used-before-assignment false positive (#1266)Łukasz Rogalski2017-01-041-2/+3
|
* Check if a name is locally assigned when looking for used-before-assignmentŁukasz Rogalski2017-01-031-1/+10
| | | | | | | | | | | | If a name is locally assigned and there is another global name with the same variable, this can result in an UnboundLocalError, as seen in the following example: x = 24 def test(a): if x == a: for x in [1, 2, 3]: print(x) test(24) In this case, we should emit an ``used-before-assignment`` message. Closes #1081
* Don't emit used-before-assignment in certain single statement functionsClaudiu Popa2016-12-181-1/+9
| | | | | | | | | If a single statement function has a particular variable and the statement is on the same line as the function definition, then we were going to emit used-before-assignment for that particular value. This was wrong, since the variable was used after the definition. Part of #1135
* New refactoring checker: consider-using-ternary (#1210)Łukasz Rogalski2016-12-181-1/+1
| | | | | This check is emitted when pylint encounters constructs which were used to emulate ternary statement before it was introduced in Python 2.5. Close #1204
* Improve metaclass detection in nested scopes in Python 3 (#1202)Łukasz Rogalski2016-12-161-45/+57
| | | | | Closes #1177
* Aliasing an import with underscore skips unused-import checkDerek Gustafson2016-12-141-0/+2
| | | Close #1190
* Add a new option for finding unused global variables.Łukasz Rogalski2016-12-131-1/+21
| | | | Closes #919
* Skip checking only of arguments when in a singledispatched function.Claudiu Popa2016-12-041-5/+3
|
* Don't emit unused-argument and function-redefined for singledispatch ↵Łukasz Rogalski2016-12-041-0/+4
| | | | | | implementations Closes #1032 and #1034
* Treat keyword only arguments the same as positional arguments with regard to ↵Claudiu Popa2016-11-201-1/+4
| | | | | | unused-argument check Close #1086
* Don't warn about used-before-assignment if the variable is in an exclusive ↵Claudiu Popa2016-08-231-3/+1
| | | | | | | | | | | | | | | except branch with NameError as a handler Until now, we weren't emitting a warning in the case of a variable being referenced before actual definition, with the variable access being placed inside a TryExcept, with an except handler that caught NameError, Exception and BaseException. While for NameError it makes sense, since it is explicit that the user is expecting a variable to not be defined, it does not make that much sense for the rest of the exceptions, even if they are supertypes of NameError anyway. This is because it is not explicit and we cannot infer what the user intended to do anyway. We are now only handling NameError. Close #1080
* Allow underscores in unused-variables. (#1058) (#1059)Grant Welch2016-08-141-1/+1
| | | | | | | | | Allow underscores in unused-variables Pylint should ignore dummy variables that contain underscores. This test demonstrates that the default value for dummy-variables-rgx fails in this regard. Closes #1058
* Kill assign_names, it is just nodes_of_class after all.Claudiu Popa2016-07-281-1/+1
|
* assign_names return only AssignName nodes now, instead of strings.Claudiu Popa2016-07-281-1/+1
|
* Use attributes from modules instead of cluttering the namespace.Claudiu Popa2016-07-271-52/+45
|
* Move _for_loop_assign_names into utils.assign_name so it can be reused.Claudiu Popa2016-07-271-25/+2
|
* Even more granular copyrights (thanks to copyrite)Claudiu Popa2016-07-231-2/+8
|
* Keep a consistent copyright notice across the board.Claudiu Popa2016-07-191-0/+2
| | | | | This was changed automatically in #894, but apparently we need to have the copyright notice somewhere.
* Added check for an inner loop reusing an outer loop's target(s)Ashley Whetter2016-07-151-1/+53
| | | | Closes #999
* ignored-argument-names is now used for ignoring arguments for ↵Claudiu Popa2016-06-271-2/+18
| | | | | | | | | | | | | | | unused-variable check. This option was used for ignoring arguments when computing the correct number of arguments a function should have, but for handling the arguments with regard to unused-variable check, dummy-variables-rgx was used instead. Now, ignored-argument-names is used for its original purpose and also for ignoring the matched arguments for the unused-variable check. This offers a better control of what should be ignored and how. Also, the same option was moved from the design checker to the variables checker, which means that the option now appears under the ``[VARIABLES]`` section inside the configuration file. Close #862.
* Move a staticmethod into a function.Claudiu Popa2016-06-241-7/+7
|
* Remove additional star.Claudiu Popa2016-06-241-1/+1
|
* Variables prepended with underscores are now marked as unused through the ↵Claudiu Popa2016-06-241-1/+1
| | | | updated dummy-variables-rgx. Close #899
* Fix a bug where the top name of a qualified import was detected as unused ↵Claudiu Popa2016-06-141-0/+5
| | | | | | | | | | | | | | | variable. The problem originates from the fact that we do not have fully qualified name of the imports in scope locals, but only the top most one. As such, we retrieve the full name from the node itself or the alias if there is any. There could be a possibility of this change to emit the message about a wrong variable when multiple imports from the same package are on the same line, but this isn't a concern, since according to best practices, the imports should be on different lines (so accessing the first item of the node is by design) Close #923.
* Install the backport of lru_cache and use it for overriden_method (the same ↵Claudiu Popa2016-06-141-0/+5
| | | | behaviour before changing it to a function per stmt).
* Capitalize some comments.Claudiu Popa2016-06-141-6/+7
|
* Simplify the function that looks for undefined variables by moving most of ↵Claudiu Popa2016-06-141-54/+61
| | | | it into another smaller function
* Make pylint work with the astroid's master branch, including the special ↵Claudiu Popa2016-06-051-14/+9
| | | | | | | | | model changes One change was to check for BaseInstance instead of Instance when looking if an instance supports a given protocol. The latter is used for class instances, while the first one can be used for builtins as well. Also the global-variable-not-assigned code was simplified.
* Add the new shorter license header, including to missing files. Close #894.Claudiu Popa2016-06-011-15/+3
|
* Do not emit import-error or no-name-in-module for fallback import blocks by ↵Claudiu Popa2016-05-311-6/+15
| | | | | | | | | | | default. Until now, we warned with these errors when a fallback import block (a TryExcept block that contained imports for Python 2 and 3) was found, but this gets cumbersome when trying to write compatible code. As such, we don't check these blocks by default, but the analysis can be enforced by using the new ``--analyse-fallback-block`` flag. Close #769.
* Fix typos (#916)Jakub Wilk2016-05-251-1/+1
| | | | | | | | * Split words that were inadvertently glued together * Fix typos in the documentation * Fix typos in message descriptions
* Add a new option, 'redefining-builtins-modules'.Claudiu Popa2016-03-251-3/+16
| | | | | | | The option can be used for controlling the modules which can redefine builtins, such as six.moves and future.builtins. Close #464.
* Don't use line continuation for strings.Claudiu Popa2016-03-251-6/+7
|
* Ignore __all__ elements that don't have a parentClaudiu Popa2016-03-111-0/+2
| | | | | | | | | | | There used to be a bug which involved astroid and extension modules, where the elements of the __all__ declaration didn't have a parent set. This problem was fixed though in astroid 2.0 and we can infer properly these declarations with the parent being set. Unfortunately, we can't rely on astroid 2.0 right now, so the solution for not having crashes is to skip these elements in the undefined-all-variable pattern. Close #846
* Remove trailing whitespace.Claudiu Popa2016-01-091-1/+1
|
* Treat AsyncFunctionDef just like FunctionDef nodesClaudiu Popa2016-01-091-1/+4
| | | | | | | | | When support for Python 3.5 was added, AsyncFunctionDef wasn't handled properly in terms of FunctionDef, which meant that most of the checks which involved a function were never called for AsyncFunctionDef. This led to spurious false positives which occurred when AsyncFunctionDef were analyzed. Closes #767