Skip to content

Commit

Permalink
Add missing special method names (#3282)
Browse files Browse the repository at this point in the history
Close #3281
  • Loading branch information
MatthijsBlom authored and PCManticore committed Dec 2, 2019
1 parent 04e72bc commit 6d818e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Expand Up @@ -354,3 +354,5 @@ contributors:
* Pek Chhan: contributor

* Craig Henriques: contributor

* Matthijs Blom: contributor
4 changes: 4 additions & 0 deletions ChangeLog
Expand Up @@ -7,6 +7,10 @@ What's New in Pylint 2.5.0?

Release date: TBA

* `__pow__`, `__imatmul__`, `__trunc__`, `__floor__`, and `__ceil__` are recognized as special method names.

Close #3281

* Added errors for protocol functions when invalid return types are detected.
E0304 (invalid-bool-returned): __bool__ did not return a bool
E0305 (invalid-index-returned): __index__ did not return an integer
Expand Down
11 changes: 5 additions & 6 deletions pylint/checkers/utils.py
Expand Up @@ -100,13 +100,10 @@
"__complex__",
"__int__",
"__float__",
"__neg__",
"__pos__",
"__abs__",
"__complex__",
"__int__",
"__float__",
"__index__",
"__trunc__",
"__floor__",
"__ceil__",
"__enter__",
"__aenter__",
"__getnewargs_ex__",
Expand Down Expand Up @@ -182,11 +179,13 @@
"__cmp__",
"__matmul__",
"__rmatmul__",
"__imatmul__",
"__div__",
),
2: ("__setattr__", "__get__", "__set__", "__setitem__", "__set_name__"),
3: ("__exit__", "__aexit__"),
(0, 1): ("__round__",),
(1, 2): ("__pow__",),
}

SPECIAL_METHODS_PARAMS = {
Expand Down

0 comments on commit 6d818e3

Please sign in to comment.