Pylint Rules : How To Solve Undefined Variable?
I get some message from pylint rules :  from scrapy.spiders import Spider class MySpider(Spider):           #Undefined variable 'Spider'     name = 'get'     start_urls = ['']
Solution 1:
It seems that there is a bug in pytest I ran the following tests with tox:
[tox]
skipsdist=Trueenvlist=py{27,34}-pylint{141,142,143,144,145}
[testenv]
whitelist_externals=pylintdeps=pylint141:pylint==1.4.1pylint142:pylint==1.4.2pylint143:pylint==1.4.3pylint144:pylint==1.4.4pylint145:pylint==1.4.5commands=pylint-rntest.pyon the following file
"""Custom exceptions"""classMyException(Exception):
    """My custom exception"""def__init__(self, message):
        super(MyException, self).__init__(message)
I obtain the following result:
ERROR:   py27-pylint141:commandsfailedERROR:   py27-pylint142:commandsfailedERROR:   py27-pylint143:commandsfailedERROR:   py27-pylint144:commandsfailedpy27-pylint145:commandssucceededERROR:   py34-pylint141:commandsfailedERROR:   py34-pylint142:commandsfailedERROR:   py34-pylint143:commandsfailedERROR:   py34-pylint144:commandsfailedpy34-pylint145:commandssucceededWith those errors:
************* Module test
E:7,27: Undefined variable 'self' (undefined-variable)E:7,42: Undefined variable 'message' (undefined-variable)Assuming this, the best way is to move to at least the version 1.4.5 of pylint.
Solution 2:
You do not have to declare variables in Python. And your class definition is wrong. In Python you dont need parameters and brackets for it. Class Definition Syntax
classMySpider: 
    #your code here
Post a Comment for "Pylint Rules : How To Solve Undefined Variable?"