我刚刚尝试用 Pylint 整理一些代码,最后剩下的错误是
R0902: too-many-instance-attributes (8/7)
我理解限制实例属性数量背后的基本原理,但七个似乎有点低。我也意识到 linter 不应该有最后的发言权。但是,我想知道我应该做什么,而不是:
def __init__(self, output_file=None, output_dir=None):
"""
Set the frobnicator up, along with default geometries
"""
self.margin = 30
self.pos = [0, 0]
self.sep = [5, 5]
self.cell = [20, 20]
self.frobbr = library.Frobbr()
page = self.frobbr.get_settings('page')
self.lim = [page.get_width() - self.margin,
page.get_height() - self.margin]
self.filename = output_file
self.moddir = output_dir
我应该将几何图形打包成一个字典,做其他事情来阻止 Pylint 抱怨,还是忽略它(我真的不想这样做)?