summaryrefslogtreecommitdiff
path: root/pylint/checkers/classes.py
Commit message (Collapse)AuthorAgeFilesLines
* [refactor] Create a package in order to be able to burst classes.pyPierre Sassoulas2021-12-171-2428/+0
|
* Add ``future=True`` to all ``NodeNG.statement()`` calls (#5310)Daniël van Noord2021-12-161-3/+5
| | | Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Fix assigning-non-slot false positive with setattr (#5457)Jake Lishman2021-12-151-0/+8
| | | | | | | | | | | | * Fix assigning-non-slot false positive with setattr Previously, if a class was slotted and overrode `__setattr__`, `assigning-non-slot` would be issued when assigning to attributes. With `__setattr__` defined, we cannot infer if it is an error to assign to an attribute, so we suppress the error. Fix #3793 Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Fix #5371: Correctly count arguments to static methods missing @staticmethod ↵Jacob Walls2021-12-031-1/+1
| | | | | | | | decorator (#5412) * Fix #5371: Correctly count arguments to static methods missing @staticmethod decorator * Implementations of MapReduceMixin.reduce_map_data were actually not classmethods
* Bump pylint to 2.12.2, update changelogv2.12.2Pierre Sassoulas2021-12-031-2/+1
|
* Activate and fix existing use-set-for-membership checks (#5379)Pierre Sassoulas2021-11-251-6/+6
| | | | * Activate and fix existing use-set-for-membership checks
* Bump pylint to 2.12.0, update changelogv2.12.0Pierre Sassoulas2021-11-251-2/+6
| | | | Closes #5250
* Fix a crash on psycopg2 for elif used (#5369)Pierre Sassoulas2021-11-241-14/+12
| | | | | | | | | | * Fix a crash in the ``check_elif`` extensions where an undetected if in a comprehension with an if statement within a f-string resulted in an out of range error. The checker no longer relies on counting if statements anymore and uses known if statements locations instead. It should not crash on badly parsed if statements anymore. specify the confidence of the message * Remove disable for else-if-used in pylint/checkers/classes.py Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
* Fix crash for ``protected-access`` on (outer)-class traversal (#5305)Daniël van Noord2021-11-151-1/+1
| | | | | * Fix crash for ``protected-access`` on (outer)-class traversal Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Remove redundant brackets (#5300)Marc Mueller2021-11-131-1/+1
|
* Add checker `using-final-decorator-in-unsupported-version` (#5165)Mark Byrne2021-11-091-5/+12
| | | | | | | | | | | | | | | | | | | | * Add checker `using-final-in-unsupported-version` This is one of the tasks in issue: #5134 Also: - Ensure the existing checkers for `typing.final` are used irrespective of Python version * Emit `using-final-in-unsupported-version` warning when Python version < 3.8 and none of the other `typing.final`-related warnings * Add `uninferable_final_decorators` Return any `typing.final` decorators for a given `Decorators` node. Used to determine if this decorator is used with a version of Python in which it is unsupported. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Fix crash on checking private members on ``__class__``Daniël van Noord2021-11-051-6/+10
| | | | Closes #5261
* Fix ``protected-access`` for attributes and methods of nested classes (#5232)Daniël van Noord2021-10-311-1/+15
| | | | | | | | | | | | | | | * Fix access to private function in inner class on protected-access bug * Add functional test for protected-access from inner class * Add Ikraduya to CONTRIBUTORS file * Add if statement to avoid potential bug * Fix ``protected-access`` for attributes and methods of nested classes This closes #3066 Co-authored-by: ikraduya <ikraduya@gmail.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Clean up some useless-super-delegation logic (#5193)Samuel Freilich2021-10-261-61/+45
| | | | | | | | | | | | | | * Clean up some useless-super-delegation logic In _definition_equivalent_to_call, avoid constructing a tuple and calling "all" on that. Instead, just check each condition in turn, terminating as soon as one fails. In _has_different_parameters_default_value, use a single sentinel value for a missing default instead of constructing a new one each call. Also construct the dict of comparators once instead of once each call. Restructure the logic to be less nested. Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
* Add ``mixin-class-rgx`` option (#5203)Daniël van Noord2021-10-251-1/+4
| | | | | Co-authored-by: Alpha <alpha@pokesplash.net> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* PR #5157 followup (#5192)Nick Pesce2021-10-211-10/+10
|
* Fix useless-super-delegation false positive when default keyword argument is ↵Nick Pesce2021-10-191-58/+26
| | | | | | | a variable. (#5157) Compare variable default args and simplify the logic of the checkers. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Add checkers for typing.final for Python version 3.8 or later (#5133)Mark Byrne2021-10-101-0/+35
| | | | | | | | * Add checkers for typing.final for Python version 3.8 or later - overridden-final-method - subclassed-final-class Closes #3197
* Fix return type checkers calls on ellipses functions (#5107)Daniël van Noord2021-10-061-1/+6
| | | Closes #4736
* [pre-commit.ci] pre-commit autoupdate (#5082)pre-commit-ci[bot]2021-09-281-2/+2
| | | | | | | | | | | * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/asottile/pyupgrade: v2.26.0 → v2.28.0](https://github.com/asottile/pyupgrade/compare/v2.26.0...v2.28.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Spelling and grammar fixesVille Skyttä2021-09-171-7/+7
|
* Bump pylint to 2.11.0, update changelogv2.11.0Pierre Sassoulas2021-09-161-1/+4
|
* Remove most `typing.cast()` calls (#4995)Daniël van Noord2021-09-151-5/+1
|
* Fix false positive ``unused-private-member`` for accessing attributes in a ↵yushao22021-09-141-5/+9
| | | | | | | | class using ``cls`` (#4965) * Fix false positive ``unused-private-member`` for accessing attributes in a class using ``cls`` Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Fix no-self-use and docparams extension for async functions/methods (#4986)SupImDos2021-09-111-0/+2
| | | | | | | | | | | | | | | | * Fixed 'no-self-check' for async functions. * fixed 'docparams' for async functions. * Added 'no-self-use' to the pylint disable comment in broken test. * Added small changelog entry to Pylint 2.11.0 milestone. * Added test: 'no-self-use' for async method. * Added test: revamped 'docparams' functional tests to test all missing documentation. Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* fix false positive W0238 with private staticmethod used from classmethod (#4949)Kayran Schmidt2021-09-071-1/+4
| | | Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Refactor various typing related issues (#4940)Daniël van Noord2021-09-031-7/+7
| | | | | | | | | | | | | | | * Add type annotations to ``visit`` & ``leave`` calls This adds typing to most calls that visit nodes. All other changes are due to mypy errors resulting from introduction of typing. * Fix outstanding mypy issues This removes some of the `type: ignore` comments in favour of solving the mypy issues these comments were surpressing. * Fix remaining references to node_classes Except for two references to node_classes in the changelog this should be the last of them Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Fix false positive ``protected-access`` in typing (#4937)Daniël van Noord2021-08-311-2/+6
| | | | | | | | * Fix false positive ``protected-access`` in typing Class functions can return protected members which can then be passed as arguments to other functions. When using type hints in function definitions these raised a message which they shouldn't do.
* Add ``Consider-using-f-string`` checker (#4796)Daniël van Noord2021-08-301-1/+2
| | | | | | | | | | | | | | | | * Add ``consider-using-f-string`` checker This adds a checker for normal strings which are formatted with ``.format()`` or '%'. The message is a convention to nudge users towards using f-strings. This closes #3592 * Update pylint code to use f-strings After adding `consider-using-f-strings` the codebase showed numerous cases of formatting which could be f-strings. This commit changes most of these to become f-strings, or adds ignores. * Apply suggestions from code review Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Bump pylint to 2.10.0, update changelogv2.10.0Pierre Sassoulas2021-08-201-1/+1
|
* ``astroid.const.BUILTINS`` use removed for clarity and so astroid can also ↵Pierre Sassoulas2021-08-191-3/+3
| | | | | | | | | | | | | removes it later (#4868) * Simplify the way builtins is used (remove astroid dependencies) * Replace the constant BUILTINS by the string 'builtins' This make for clearer and also slightly faster code (means time seems to decrease by 0.68% with this change alone (astroid/pylint) in the pylint tests benchmarks). Done because we were using an import from astroid from astroid.bases for one of those, which is kinda messy.
* Use alias for astroid.nodes 01 (#4855)Marc Mueller2021-08-171-114/+115
| | | | * Use from astroid import nodes * Resolve name conflicts
* Revert "Extended consider-using-tuple check to cover 'in' comparisons (#4768)"Marc Mueller2021-08-121-2/+2
| | | | This reverts commit ca3bc53fd8d628473fba25c7736d0abfac8e4a4a.
* Fix crash for `unused-private-member` when there are nested attributes (#4783)yushao22021-08-011-1/+3
| | | | | | * Fix crash for `unused-private-member` when there are nested attributes Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Fix false-positive of `unused-private-member` with class name (#4782)yushao22021-08-011-11/+21
|
* update pr based on reviewYu Shao, Pang2021-08-011-7/+2
|
* Update pr based on reviewYu Shao, Pang2021-08-011-5/+4
|
* Update pr based on reviewYu Shao, Pang2021-08-011-4/+7
|
* update PR based on commentsYu Shao, Pang2021-08-011-8/+12
|
* [unused-private-member] add logic for checking nested functionsYu Shao, Pang2021-08-011-1/+15
| | | | also, improve error message for nested functions
* Extended consider-using-tuple check to cover 'in' comparisons (#4768)Marc Mueller2021-07-291-1/+1
|
* Bump pylint to 2.9.4, update changelogv2.9.4Pierre Sassoulas2021-07-201-0/+1
|
* Applied suggestions from PR reviewYu Shao, Pang2021-07-181-7/+6
|
* [unused-private-member] add logic to check for obj attributes whenYu Shao, Pang2021-07-181-1/+21
| | | | using ``new``
* [unused-private-member] Handle case of mutating class attrib with `cls`Yu Shao, Pang2021-07-031-3/+8
|
* Fix copyright links (#4647)Marc Mueller2021-07-011-1/+1
| | | | * Fix link in license header * Update link to astroid bump_changelog
* [unused-private-member] Handle the case using self to access membersPierre Sassoulas2021-07-011-1/+1
| | | | As seen in issue #4644
* [unused-private-member] Remove boolean in favor of using for/elsePierre Sassoulas2021-07-011-18/+8
|
* [unused-private-member] Create functions for each part of the checkPierre Sassoulas2021-07-011-5/+6
|
* [unused-private-member] Remove a check that is done later anywayPierre Sassoulas2021-06-301-5/+1
| | | | See https://github.com/PyCQA/pylint/pull/4642\#discussion_r661805293