import MySQLdb
try:
dbcon = MySQLdb.connect(host=host_name, user=user_name,
passwd=password, db=db_name)
except MySQLdb.Error:
pass
getting this pylint warning Module 'MySQLdb' has no 'Error' member (no-member)
It may help to use the
--extension-pkg-whitelistoption:pylint parses (by default) the source files, but in Python the shape of a module can change at runtime from the shape defined in the source file. This option tells pylint to actually import the specified module, and use the runtime definition.
Note that since the MySQLdb package wraps a C extension, you have to pass the name of the C extension (
_mysql) instead of the package name (MySQLdb). (source)You could use the
unsafe-load-any-extensionoption, but that would load every available extension, with its' (potentially dangerous) initialization code.extension-pkg-whitelistis safer, because it only loads the specified modules.