summaryrefslogtreecommitdiff
path: root/pylint/checkers/classes.py
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Correct infered to inferredClaudiu Popa2019-05-201-12/+12
|
* Exclude ``__dict__`` from ``attribute-defined-outside-init``Claudiu Popa2019-05-191-0/+3
| | | | Close #2909
* Style - Apply isort on all apllicable filesPierre Sassoulas2019-03-201-16/+15
|
* ``assigning-non-slot`` not emitted for classes with unknown base classes.Claudiu Popa2019-03-111-35/+37
| | | | | | | | | It's possible to lint classes that don't have known bases (e.g. one of them might come from a C extension), in which case we cannot make a lot of assumptions about the class layout with respect to `__slots__`. As such, it's best to ignore these classes from this check. Close #2807
* Add missing check_messages() for visit_classdef in classes checksClaudiu Popa2019-03-031-0/+12
|
* Added a new check `class-variable-slots-conflict`Claudiu Popa2019-03-031-10/+21
| | | | | This check is emitted when ``pylint`` finds a class variable that conflicts with a slot name, which would raise a ``ValueError`` at runtime.
* Take into account `__class_getitem__` Pascal Corpet2019-02-041-1/+1
| | | | | | | | Take into account `__class_getitem__` from PEP 560 and fixes some false positives for `no-self-argument` and `unsubscriptable-object` PEP: https://www.python.org/dev/peps/pep-0560/ Close #2416
* Adding implicit-str-concat-in-sequence check (#1655)Lucas Cimon2018-10-101-9/+9
| | | | | ``implicit-str-concat-in-sequence`` detects string concatenation inside lists, sets & tuples. It would warn on code such as `('a', 'b' 'c')`.
* Reformat the code with blackClaudiu Popa2018-09-171-445/+634
|
* Infer decorated methods when looking for method-hiddenClaudiu Popa2018-08-231-9/+21
| | | | Close #2369
* Stop protected-access exception for missing class attributesBryce Guinta2018-08-081-0/+2
| | | | Skip Uninferable values from getattr
* Update copyright noticesClaudiu Popa2018-07-151-1/+7
|
* Merge branch 'master' into fix_2177Sushobhit2018-06-221-1/+1
|\
| * Use as_string() to get the representation of an annotation, not name, which ↵Claudiu Popa2018-06-211-1/+1
| | | | | | | | can be missing. Close #2210
* | adapt existing test cases for useless-object-inheritance.ssolanki2018-06-211-1/+1
| | | | | | | | | | | | | | | | | | | | adapt existing test/input test cases to new check. add some more positive test case for useless-object-inheritance msg code was in conflict with existing msg. adapt existing test cases for new checker.
* | Add new checker useless-object-inheritance.ssolanki2018-06-201-1/+8
|/ | | | Close #2177
* `mcs` as the first parameter of metaclass's `__new__` method was replaced by ↵Claudiu Popa2018-06-061-1/+1
| | | | | | `cls` Close #2028
* Fixed emitting ``useless-super-delegation`` when changing the default value ↵Ashley Whetter2018-06-021-2/+3
| | | | | | of keyword arguments Closes #2022
* Fixed method-hidden raised when assigned to data descriptorsAshley Whetter2018-06-011-0/+8
| | | | Closes #1061
* Remove unused functionClaudiu Popa2018-05-261-9/+0
|
* Kill YES in favour of UninferableClaudiu Popa2018-05-241-5/+5
|
* pyupgrade (#2136)Anthony Sottile2018-05-221-1/+1
|
* Don't emit 'useless-super-delegation' if annotations are differentBen Green2018-05-151-0/+11
| | | | Fixes #1923
* Fix lint errors caused by the new checker changeClaudiu Popa2018-04-021-3/+2
|
* Spelling fixesVille Skyttä2018-01-301-1/+1
|
* Rip some of the six imports from the codebaseClaudiu Popa2018-01-251-10/+9
|
* Set max-returns to 11Nick Drozd2018-01-041-21/+16
| | | | | | Previously, the greatest number of return statements in a function was 15 (checkers.typecheck). 11 is the lowest I could get it without aggressive rewriting.
* Regenerate copyright noticesClaudiu Popa2017-12-151-4/+16
|