summaryrefslogtreecommitdiff
path: root/pylint/checkers/classes.py
Commit message (Collapse)AuthorAgeFilesLines
* Prepare 2.7.3 release (#4261)pylint-2.7.32.7Pierre Sassoulas2021-03-291-0/+1
|
* Import astroid with import x or from x import y but not bothPierre Sassoulas2021-03-281-17/+13
| | | | Remove unused imports for astroid
* Fix private method hidden by ancestor class attribute (#4177)tiagohonorato2021-03-211-0/+2
| | | | | | | | | | | | | | * Fix private method hidden by ancestor class attribute A class defined private method won't be hidden by an ancestor class private attribute as the class will mangle the latter to avoid naming collisions. Add tests to assert method-hidden : Although private attributes from the parent class should not hide methods in the child class, this is not true for protected attributes. This test ensures that ``method-hidden`` catches the error when private attributes are not in use. Signed-off-by: Tiago Honorato <tiagohonorato1@gmail.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Remove TypedDict hotfixMarc Mueller2021-02-281-5/+0
|
* Apply copyrite --contribution-thresholdPierre Sassoulas2021-02-211-2/+4
|
* Migrate from % syntax or bad format() syntax to fstringPierre Sassoulas2021-02-211-1/+1
| | | | We can do that in python 3.6
* Move from % string formatting syntax to f-string or .format()Pierre Sassoulas2021-02-211-2/+2
|
* Remove the # coding, since PEP3120 the default is UTF8Pierre Sassoulas2021-02-211-1/+0
|
* Move from format() to f-string where it makes sensePierre Sassoulas2021-02-161-1/+1
| | | | As we do not maintain python 3.5 it permit to simplify some code
* Fix W504 line break after binary operatorPierre Sassoulas2021-02-151-4/+2
|
* Fix TypedDict inherit-non-class false-positive Python 3.9+Marc Mueller2021-02-151-0/+5
| | | | * Closes #1927
* Fix signature-differsGergelyKalmar2020-12-201-1/+4
|
* Taking into account @Pierre-Sassoulas remarkshippo912020-09-271-5/+7
|
* Adds an option to the ClassChecker to activate/deactivate protected-access ↵hippo912020-09-261-5/+15
| | | | message emission for single underscore prefixed attributes inside special method
* Remove unsecable whitespace in the whole codebasePierre Sassoulas2020-09-121-4/+4
|
* Update formatting following black and isort updatePierre Sassoulas2020-09-101-6/+4
|
* Merge branch 'master' into bug_pylint_3468hippo912020-09-061-0/+1
|\
| * def _has_different_parameters_default_value method add the astroid.DIct ↵hippo912020-08-171-0/+1
| | | | | | | | class in the type to be compared for default arguments.
* | Corrects some inconsistent-return-statements occurenceshippo912020-08-201-0/+1
|/
* `property-with-parameters` properly handles abstract propertiesClaudiu Popa2020-05-141-1/+6
| | | | Close #3600
* Fix a crash in `method-hidden` lookup for unknown base classesClaudiu Popa2020-04-281-9/+4
| | | | | | | | The patch replaces `mro()` with `ancestors()` as the former is not fully capable of generating the complete linearization when dealing with ambiguous inferences. Close #3527
* Add missing copyright annotations for the past releasesClaudiu Popa2020-04-271-6/+17
|
* Positional-only arguments are taken in account for ``useless-super-delegation``Claudiu Popa2020-03-281-6/+13
|
* Fix R1721: Unnecessary use of a comprehensionPierre Sassoulas2020-03-271-1/+1
|
* Fix overzealous `arguments-differ` for variadicsmattlbeck2020-03-271-15/+25
| | | | | | | | | No message is emitted if the overriding function provides positional or keyword variadics in its signature that can feasibly accept and pass on all parameters given by the overridden function. Closes #1482 Closes #1553
* 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/) ```
* Correct some types and guard against unexpected values in classes checkersClaudiu Popa2020-03-081-1/+1
|
* ``no-self-use`` is no longer emitted for typing stubs.Claudiu Popa2020-03-071-0/+2
| | | | Close #3439
* Add async def checks for overridden methods (#3392)craig-sh2020-02-121-3/+20
| | | Close #3355
* Enable else-if-used extension (#3316)Nick Drozd2019-12-241-1/+1
| | | After all, if we don't use this, why should anybody else?
* Fix a false positive caused by the newly added support for propertiesClaudiu Popa2019-12-041-4/+8
|
* Enhance the protocol checker (#3259)craig-sh2019-11-271-26/+208
| | | | | | | | | | | | | | | | This commit adds multiple checks for various Python protocols E0304 (invalid-bool-returned): __bool__ did not return a bool E0305 (invalid-index-returned): __index__ did not return an integer E0306 (invalid-repr-returned): __repr__ did not return a string E0307 (invalid-str-returned): __str__ did not return a string E0308 (invalid-bytes-returned): __bytes__ did not return a string E0309 (invalid-hash-returned): __hash__ did not return an integer E0310 (invalid-length-hint-returned): __length_hint__ did not return a non-negative integer E0311 (invalid-format-returned): __format__ did not return a string E0312 (invalid-getnewargs-returned): __getnewargs__ did not return a tuple E0313 (invalid-getnewargs-ex-returned): __getnewargs_ex__ did not return a tuple of the form (tuple, dict) Close #560
* Reverse the order of positional args check in _check_first_arg_for_typeClaudiu Popa2019-11-081-3/+3
| | | | | | | | Because the positional only arguments can appear before the normal positional or keyword arguments, we need to first check the positional only ones for the purpose of bad-mcs-* and similar methods. Close #3230
* Return early in visit_class to get rid of a too many branchesClaudiu Popa2019-10-301-14/+17
|
* Catch invalid MRO constructs when ignoring method-hiddenClaudiu Popa2019-10-301-5/+9
|
* Fixed method-hidden when subclass defines the method (#3206)Ashley Whetter2019-10-301-0/+6
|
* Refactor file checking for a simpler parallel API (#3016)Janne Rönkkö2019-10-181-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change prepares the code for enabling Prospector to take advantage of running PyLint parallel. Iterating files is moved into generator (_iterate_file_descrs) so that parallel checking can use the same implementation (_check_file) just by providing different kind of generator that reads the files from parent process. The refactoring removes code duplication that existed in PyLinter._do_check method; checking module content from stdin had identical implementation to checking content from a source file. Made PyLinter.expand_files a private method. The previous implementation of parallel linting created new PyLinter objects in the worker (child) process causing failure when running under Prospector because Prospector uses a custom PyLinter class (a class inherited from PyLinter) and PyLint naturally just creates PyLinter object. This caused linting to fail because there is options for Prospector's IndentChecker which was not created in the worker process. The new implementation passes the original PyLinter object into workers when the workers are created. See https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods Note that as Windows uses spawn method by default, PyLinter object (and its) members need to be pickleable from now on with the exception being PyLinter.reporter which is not passed to child processes. The performance has remained about the same based on quick tests done with Django project containing about 30 000 lines of code; with the old implementation linting took 26-28 seconds with 8 jobs on quad core i7 and 24-27 seconds with the new implementation.
* Do not emit ``no-method-argument`` for functions using positional only args.Claudiu Popa2019-10-111-2/+7
| | | | Close #3161
* Exempt annotated assignments without variable from ↵Claudiu Popa2019-09-301-1/+6
| | | | | | ``class-variable-slots-conflict`` Close #3141
* Remove redundant compatibility code (#3097)Hugo van Kemenade2019-09-121-7/+1
| | | | We no longer support Python 2 so we can remove the compatibility code we had in place for that version.
* [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.
* Don't require super call from `typing.overload`-ed __init__Grygorii Iermolenko2019-08-161-1/+3
| | | | Close #3020
* Don't emit protected-acces for single underscore prefixed attributes in ↵hippo912019-08-061-0/+17
| | | | | | | | | special methods This PR prevents the emission of protected-access message when a single underscore prefixed attribute is accessed inside a special method. Close #1802
* Added a new check, ``invalid-overridden-method``Claudiu Popa2019-07-181-4/+34
| | | | | | | | This check is emitted when we detect that a method is overridden as a property or a property is overridden as a method. This can indicate a bug in the application code that will trigger a runtime error. Close #2670
* Added a new check, ``property-with-parameters``.Claudiu Popa2019-07-161-0/+11
| | | | | | This check is emitted when we detect that a defined property also has parameters, which are useless. Close #3006
* Excluded protocol classes from a couple of checks. Close #3002.Claudiu Popa2019-07-161-0/+2
|
* Fix - add `__post_init__` into `defining-attr-methods` to avoid ↵Andrzej Klajnert2019-07-051-1/+1
| | | | `attribute-defined-outside-init` in dataclasses.
* Fix a bunch of linting errors from the codebaseClaudiu Popa2019-05-221-4/+2
|
* Don't emit ``attribute-defined-outside-init`` for variables defined in setters.Claudiu Popa2019-05-211-6/+13
| | | | Close #409
* Add a function to figure out if a node is a property setter and use it ↵Claudiu Popa2019-05-211-7/+3
| | | | accordingly