Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid "undefined variable __class__" #1328

Closed
anntzer opened this issue Feb 17, 2017 · 2 comments
Closed

Invalid "undefined variable __class__" #1328

anntzer opened this issue Feb 17, 2017 · 2 comments
Labels

Comments

@anntzer
Copy link

anntzer commented Feb 17, 2017

Steps to reproduce

$ cat /tmp/test.py
class Class:
    def method(self):
        print(__class__)


Class().method()
$ pylint --rcfile=/dev/null /tmp/test.py
************* Module test
C:  1, 0: Missing module docstring (missing-docstring)
C:  1, 0: Missing class docstring (missing-docstring)
C:  2, 4: Missing method docstring (missing-docstring)
E:  3,14: Undefined variable '__class__' (undefined-variable)
R:  2, 4: Method could be a function (no-self-use)
R:  1, 0: Too few public methods (1/2) (too-few-public-methods)

----------------------------------------------------------------------
Your code has been rated at -15.00/10 (previous run: -15.00/10, +0.00)

Current behavior

pylint thinks __class__ is undefined.

Expected behavior

__class__ is actually defined (on Py3) and set to the containing class.

pylint --version output

No config file found, using default configuration
pylint 2.0.0, 
astroid 1.5.0
Python 3.6.0 (default, Jan 16 2017, 12:12:55) 
[GCC 6.3.1 20170109]
@rogalski
Copy link
Contributor

Thanks for reporting a bug!

@PCManticore
Copy link
Contributor

Thank you. I didn't know this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants