Possible bug with checkers.utils.is_subclass_of()
Hello everyone. I'm getting an error using pylint. Currently in my execution the function `checkers.utils.is_subclass_of()`[1] is raising a `NoneType object has no attribute name` exception. Debugging the issue I could check one of the arguments (nodes) used by this function is `None`. I think the expected behavior would be the function return False when one of the nodes is None. But the problem is in this `if` statement[2]. The check is done using `if not any()` but probably the correct way would be check it using `if not all()` to ensure all nodes is subclass of `astroid.ClassDef`. Could anyone double check it with me? If a patch is necessary I can tackle it. My environment details: pylint 2.1.1 astroid 2.0.3 Python 3.7.0 (default, Aug 8 2018, 09:38:40) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] [1] - https://github.com/PyCQA/pylint/blob/master/pylint/checkers/utils.py#L1001 [2] - https://github.com/PyCQA/pylint/blob/master/pylint/checkers/utils.py#L1011 Thanks, -- Caio Carrara Software Engineer, Virt Team Red Hat ccarrara@redhat.com
Hi Caio, You are right, that should have been `if not all()` instead. If you can provide a patch for this bug, that would be amazing! Thank you, Claudiu On 16 August 2018 at 18:28, Caio Carrara <ccarrara@redhat.com> wrote:
Hello everyone.
I'm getting an error using pylint.
Currently in my execution the function `checkers.utils.is_subclass_of()`[1] is raising a `NoneType object has no attribute name` exception. Debugging the issue I could check one of the arguments (nodes) used by this function is `None`.
I think the expected behavior would be the function return False when one of the nodes is None. But the problem is in this `if` statement[2]. The check is done using `if not any()` but probably the correct way would be check it using `if not all()` to ensure all nodes is subclass of `astroid.ClassDef`.
Could anyone double check it with me? If a patch is necessary I can tackle it.
My environment details: pylint 2.1.1 astroid 2.0.3 Python 3.7.0 (default, Aug 8 2018, 09:38:40) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
[1] - https://github.com/PyCQA/pylint/blob/master/pylint/checkers/utils.py#L1001 [2] - https://github.com/PyCQA/pylint/blob/master/pylint/checkers/utils.py#L1011
Thanks, -- Caio Carrara Software Engineer, Virt Team Red Hat ccarrara@redhat.com _______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality
participants (2)
-
Caio Carrara -
Claudiu Popa