[code-quality] Possible bug with utils.is_subclass_of()

Caio Carrara ccarrara at redhat.com
Tue Aug 14 17:27:10 EDT 2018


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, Virtualization Team
Red Hat
ccarrara at redhat.com


More information about the code-quality mailing list