test.py with contentclass Class:
def method(self):
print(__class__)
Class().method()
pylint-3 --disable=R --disable=C test.py************* Module test
/test.py:3:14: E0602: Undefined variable '__class__' (undefined-variable)
--------------------------------------------------------------------
Your code has been rated at -2.50/10 (previous run: -6.67/10, +4.17)
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
pylint-3 2.3.1
astroid 2.3.0
Python 3.8.0b4 (default, Aug 30 2019, 00:00:00)
[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]
This is on Fedora rawhide with Python 3.8.
The expected behaviour is from Fedora 30 with Python 3.7:
pylint-3 2.3.1
astroid 2.2.5
Python 3.7.4 (default, Jul 9 2019, 16:32:37)
[GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
Similar issue was reported before (and resolved) as https://github.com/PyCQA/pylint/issues/1328.
Thanks, I can reproduce the issue.
Actually, this does not seem to be Python 3.8 specific. I see the issue on Fedora 31 (run in registry.fedoraproject.org/fedora:31 container) with Python 3.7 as well:
# pylint-3 --version
pylint-3 2.3.1
astroid 2.3.0
Python 3.7.4 (default, Aug 12 2019, 14:45:07)
[GCC 9.1.1 20190605 (Red Hat 9.1.1-2)]
Is astroid (2.3.0 vs. 2.2.5 on Fedora 30 where the issue does not manifest itself) the culprit?
I agree, it's not Python version related issue. I got this one with the new Pylint version and Python 3.5 :
pylint 2.4.2
astroid 2.3.1
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516]
and I think @adelton is right, it is related to astroid version (>= 2.3)
Hi, any plans to fix it? Or are there any problems causing that it cannot be fixed? I'm not happy to use the self.__class__ workaround. Do you have any suggestions how to workaround it nicely? Is it a bad habit to use __class__ at all?
(I get this error E0602: Undefined variable '__class__' (undefined-variable) with pylint 2.4.4 and python 3.6.9).
Most helpful comment
Hi, any plans to fix it? Or are there any problems causing that it cannot be fixed? I'm not happy to use the
self.__class__workaround. Do you have any suggestions how to workaround it nicely? Is it a bad habit to use__class__at all?(I get this error E0602: Undefined variable '
__class__' (undefined-variable) with pylint 2.4.4 and python 3.6.9).