summaryrefslogtreecommitdiff
path: root/pylint/checkers/refactoring.py
Commit message (Collapse)AuthorAgeFilesLines
* Move refactoring to a package in order to burst itPierre Sassoulas2020-09-051-1672/+0
|
* Add simplifiable-condition and condition-evals-to-constant to the ↵ethan-leba2020-08-311-1/+94
| | | | refactoring checker
* Add bool() check for len-as-conditionethan-leba2020-08-311-21/+26
|
* Sets up copyrighthippo912020-08-201-0/+1
|
* Minor typo fix in R1721 help stringlrjball2020-07-041-1/+1
| | | typo fix, identitiy -> identity
* Address the super violations in the codebaseClaudiu Popa2020-05-051-5/+8
|
* Rename the new old-style super with super-with-argumentsClaudiu Popa2020-05-051-0/+23
| | | | | Also move it from the Python 3 checker to the refactoring one, as it's a better fit for it.
* Add missing copyright annotations for the past releasesClaudiu Popa2020-04-271-4/+17
|
* Fix false-negative cases for trailing-comma-tupleYang Yang2020-04-191-1/+1
| | | | | | | The current logic for detecting trailing-comma-tuple violations fails to detect positive cases that span multiple lines because its look-back mechanism stops at the last NL or NEWLINE token when it should in fact stop at the last NEWLINE token only.
* Refactor the dict.get detection code to be easier to understandClaudiu Popa2020-04-031-18/+41
| | | | Also add support for astroid.Index unpacking, which is gone in Python 3.9.
* Pick a different name than slice to avoid overshadowing a builtinClaudiu Popa2020-03-271-5/+5
|
* Properly unwrap astroid.Index on Python 3.9+Claudiu Popa2020-03-271-4/+6
|
* pyupgrade: automated removal of python2 constructsAnthony Sottile2020-03-241-1/+0
| | | | | | | | | | | | | using configuration: ```yaml - repo: https://github.com/asottile/pyupgrade rev: v2.1.0 hooks: - id: pyupgrade args: [--py3-plus, --keep-percent-format] exclude: ^tests/(extensions/data/|functional/|input/|regrtest_data/) ```
* Protect against passing a non-class to ↵Claudiu Popa2020-03-081-1/+1
| | | | _check_exception_inherit_from_stopiteration
* Protect against `exc` not having `pytype`Claudiu Popa2020-03-081-1/+1
| | | | | `pytype` is not defined on all nodes, but line 1175 assumed the result of `safe_infer()` might have it.
* ``consider-using-sys-exit`` is no longer emitted when `exit` is imported in ↵Claudiu Popa2019-10-111-5/+12
| | | | | | the local scope. Close #3147
* properly handle literals in ``unnecessary-comprehension`` checker, closes #3148Rémi Cardona2019-10-031-1/+3
|
* expand nested ternaries in ``unnecessary-comprehension`` to proper if statementsRémi Cardona2019-10-031-9/+6
|
* ``consider-using-sys-exit`` is exempted when `exit()` is imported from `sys`Claudiu Popa2019-09-301-1/+9
| | | | Close #3145
* Simplify and improve the logic of consider-iterating-dictionaryClaudiu Popa2019-09-241-4/+9
|
* Report unnecessary else after continue and breakRobert Schweizer2019-09-101-0/+32
| | | | Close #2327
* Added a new check, consider-using-sys-exit, close #2925 (#3062)Sushobhit2019-08-221-0/+11
| | | Close #2925
* [pylint.checkers] Make the link between msgid and symbol strictly 1-1Pierre Sassoulas2019-08-191-2/+2
| | | | | Will permit to improve performance with less check but more importantly simplify the message store a lot.
* blacken the codePHeanEX2019-07-161-17/+36
| | | | I mean its ugly now, but if you want it like that: Here you go
* Add new checker (unnecessary-comprehension) (close #2905)PHeanEX2019-07-161-0/+41
|
* Ignore ``consider-using-dict-comprehension`` for constructions that can't be ↵Claudiu Popa2019-06-201-3/+10
| | | | | | converted to a comprehension Close #2963
* Style - Apply isort on all apllicable filesPierre Sassoulas2019-03-201-5/+2
|
* Make ``len-as-condition`` only fire when a ``len(x)`` call is made without ↵Paul Renvoise2019-03-191-136/+76
| | | | | | | an explicit comparison This commit reduce the scope of `len-as-condition` to only care when a `len(SEQUENCE)` call is made without an explicit comparison, as stated in PEP8.
* Kill some old names in favour of their corresponding check classClaudiu Popa2019-02-131-3/+3
|
* Generalize `chained-comparison` (#2655)Justin Li2018-12-211-39/+42
| | | | | | | | | | | | | | | `chained-comparison` detects boolean expressions such as `a < b and b < c` and suggests it should be rewritten as `a < b < c`. The current implementation is limited in two ways. First, cannot deal with existing chain comparisons, so it would not detect the following: `a < b < c and c < d` # should be a < b < c < d Second, the algorithm for detecting possible chains is simplistic, and would falsely detect the following: `a < b < c and b < d` # no simplification possible This change fixes both of these issues.
* Add ``no-else-raise`` warning (R1720) (#2636)Jim Robertson2018-12-111-6/+31
| | | Close #2558
* Fix incorrect generation of ``no-else-raise`` warnings (R1705) (#2618)Jim Robertson2018-12-071-14/+4
| | | | | | | | Fixed issue where ``if`` statements with nested ``if`` statements were incorrectly being flagged as ``no-else-raise`` in some cases and not being flagged as ``no-else-raise`` in other cases. Added tests for verification and updated pylint source files to eliminate newly exposed warnings.
* Adding implicit-str-concat-in-sequence check (#1655)Lucas Cimon2018-10-101-4/+4
| | | | | ``implicit-str-concat-in-sequence`` detects string concatenation inside lists, sets & tuples. It would warn on code such as `('a', 'b' 'c')`.
* No enumerate check in __iter__ (#2505)Ben James2018-09-221-0/+4
| | | | | | Don't suggest enumerate when defining `__iter__` and operating on the underlying class Closes #2477
* Added check simplifiable-if-expression (#2502)Tomer Chachamu2018-09-201-0/+34
| | | | | | Similar to simplifiable-if-statement, it finds trivial ternary statements and suggested replacing them. Paired-with: Richard Goodman <richardg@brandwatch.com>
* Reformat the code with blackClaudiu Popa2018-09-171-337/+481
|
* ``consider-using-ternary`` and ``simplified-boolean-expression`` no longer ↵Claudiu Popa2018-09-051-15/+0
| | | | | | | | emit for sequence based checks This was more of an heuristic than actual an useful check, so let's get rid of it. Close #2473
* ``simplifiable-if-statement`` not emitted when dealing with subscriptsClaudiu Popa2018-08-031-0/+2
|
* `trailing-comma-tuple` gets emitted for ``yield`` statements as well.Claudiu Popa2018-07-311-1/+3
| | | | Close #2363
* Get only the arguments of the scope function for `redefined-argument-from-local`Claudiu Popa2018-07-311-1/+2
| | | | Close #2364
* Change refactoring nodes_of_class call to use skip_klass (#2351)Nick Drozd2018-07-271-4/+2
| | | | | | Calling nodes_of_class without a skip_klass and then filtering afterwards is slightly inefficient, but more importantly it's an unusual use of the function (this is the only example in Pylint where Return nodes are extracted without skipping FunctionDef).
* Don't crash when `pylint` is unable to infer the value of an argument to ↵Claudiu Popa2018-07-191-1/+1
| | | | | | `next()` Close #2316
* Don't emit `useless-return` when we have a single statement that is the ↵Claudiu Popa2018-07-171-2/+1
| | | | | | | | | return itself We still want to be explicit when a function is supposed to return an optional value; even though `pass` could still work, it's not explicit enough and the function might look like it's missing an implementation. Close #2300
* Include the type of the next branch in `no-else-return`Claudiu Popa2018-07-171-3/+7
| | | | Close #2295
* Update copyright noticesClaudiu Popa2018-07-151-4/+10
|
* Validate that the next() builtin is called when looking for ↵Claudiu Popa2018-07-151-0/+4
| | | | stop-iteration-return, and ignore attributes named the same
* `trailing-comma-tuple` can be emitted for `return` statements as well.Claudiu Popa2018-07-101-1/+1
| | | | Close #2269
* Infer the value of the truth_value before looking for consider-using-ternary ↵Claudiu Popa2018-07-081-3/+10
| | | | | | | | | | and simplifiable-boolean-expression The reason for that is that a Name node, for instance, will not have a bool_value() implementation, thus it will default to returning Uninferable. In order to avoid that, just infer the object before verifying anything about it. Related to #2058
* Do not emit consider-using-ternary when all the elements involved are a ↵Claudiu Popa2018-07-081-0/+2
| | | | Compare node (might not be simplifiable to a ternary).
* Check Slice is type index (fix #2252)Konstantin Manna2018-07-051-0/+1
|