diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-03-31 08:49:01 +0200 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2022-03-31 09:45:04 +0200 |
commit | 9009189c06dd326b7a4f5b9911d0246976f64509 (patch) | |
tree | 77a543ce083685d3b55ae3a178e4e73ddc436264 | |
parent | 881262641ee1ca6fd6704b66b2b4ae37597e8fef (diff) | |
download | pylint-git-9009189c06dd326b7a4f5b9911d0246976f64509.tar.gz |
Fix crash in ``super-init-not-called`` checker (#6043)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pylint/checkers/classes/class_checker.py | 11 | ||||
-rw-r--r-- | tests/functional/s/super/super_init_not_called.py | 7 | ||||
-rw-r--r-- | tests/functional/s/super/super_init_not_called.txt | 1 |
4 files changed, 19 insertions, 5 deletions
@@ -30,6 +30,11 @@ Release date: TBA Closes #6028 +* Fix crash in ``super-init-not-called`` checker when using ``ctypes.Union``. + + Closes #6027 + + * Fix crash for ``unneccessary-ellipsis`` checker when an ellipsis is used inside of a container or a lambda expression. Closes #6036 diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py index f5efc4dc7..a426b9960 100644 --- a/pylint/checkers/classes/class_checker.py +++ b/pylint/checkers/classes/class_checker.py @@ -1999,11 +1999,12 @@ a metaclass class method.", # Return if any of the klass' first-order bases is protocol for base in klass.bases: - # We don't need to catch InferenceError here as _ancestors_to_call - # already does this for us. - for inf_base in base.infer(): - if inf_base.qname() in utils.TYPING_PROTOCOLS: - return + try: + for inf_base in base.infer(): + if inf_base.qname() in utils.TYPING_PROTOCOLS: + return + except astroid.InferenceError: + continue if decorated_with(node, ["typing.overload"]): continue diff --git a/tests/functional/s/super/super_init_not_called.py b/tests/functional/s/super/super_init_not_called.py index c8e9f09d1..90a884b0b 100644 --- a/tests/functional/s/super/super_init_not_called.py +++ b/tests/functional/s/super/super_init_not_called.py @@ -48,3 +48,10 @@ class ChildTwo(ParentWithoutInit): class ChildThree(ParentWithoutInit): def __init__(self): # [super-init-not-called] ... + + +# Regression test as reported in +# https://github.com/PyCQA/pylint/issues/6027 +class MyUnion(ctypes.Union): + def __init__(self): # [super-init-not-called] + pass diff --git a/tests/functional/s/super/super_init_not_called.txt b/tests/functional/s/super/super_init_not_called.txt index 615b24a54..aafaa2023 100644 --- a/tests/functional/s/super/super_init_not_called.txt +++ b/tests/functional/s/super/super_init_not_called.txt @@ -1,2 +1,3 @@ undefined-variable:18:23:18:40:UninferableChild:Undefined variable 'UninferableParent':UNDEFINED super-init-not-called:49:4:49:16:ChildThree.__init__:__init__ method from base class 'ParentWithoutInit' is not called:INFERENCE +super-init-not-called:56:4:56:16:MyUnion.__init__:__init__ method from base class 'Union' is not called:INFERENCE |