pylint 属性定义外初始化;但属性在 __init__() 方法中
pylint attribute-defined-outside-init; but attributes are in __init__() method
我正在创建一个 class 来连接到 neo4j 数据库。 __init__()
方法设置必要的属性,验证并检查连接。
当我 运行 pylint 它在 password
、user
和 graph_url
上给出 attribute-defined-outside-init
错误;尽管我认为我确实把它们放在了正确的位置。 Python 似乎对此很满意。
这是我正在尝试做的事情:
from py2neo import authenticate, Graph
class NeoConnector(object):
"""Creates a NeoConnector object that can connect to a Neo4j graph
database and perform operations like upload nodes and relationships,
drop the database, index labels and properties."""
def __init__(self, url, user, password, database):
"""Setup the graph, authenticate and connect"""
self.graph_url = url
self.user = user
self.password = password
authenticate(url, user, password)
graph = Graph(''.join(["http://", url, database]))
try:
graph.neo4j_version
except:
print """\nDisconnected from Neo4j.
Please check if the cord is unplugged."""
print graph
print ''
else:
print '\nConnected to Neo4j; version:', graph.neo4j_version
知道我做错了什么吗?
我只能找到其他有关在 init() 方法之外设置属性的问题。
不应该
def __init_
被拼写
def __init__
?
虽然正确,但这仍然没有奏效。我最终重新安装了 pylint,现在错误不再显示了。
我正在创建一个 class 来连接到 neo4j 数据库。 __init__()
方法设置必要的属性,验证并检查连接。
当我 运行 pylint 它在 password
、user
和 graph_url
上给出 attribute-defined-outside-init
错误;尽管我认为我确实把它们放在了正确的位置。 Python 似乎对此很满意。
这是我正在尝试做的事情:
from py2neo import authenticate, Graph
class NeoConnector(object):
"""Creates a NeoConnector object that can connect to a Neo4j graph
database and perform operations like upload nodes and relationships,
drop the database, index labels and properties."""
def __init__(self, url, user, password, database):
"""Setup the graph, authenticate and connect"""
self.graph_url = url
self.user = user
self.password = password
authenticate(url, user, password)
graph = Graph(''.join(["http://", url, database]))
try:
graph.neo4j_version
except:
print """\nDisconnected from Neo4j.
Please check if the cord is unplugged."""
print graph
print ''
else:
print '\nConnected to Neo4j; version:', graph.neo4j_version
知道我做错了什么吗?
我只能找到其他有关在 init() 方法之外设置属性的问题。
不应该
def __init_
被拼写
def __init__
?
虽然正确,但这仍然没有奏效。我最终重新安装了 pylint,现在错误不再显示了。