[Python-projects] Pylint and Turbogears (SQLObject)
Thomas W Barr
Thomas.W.Barr at aero.org
Tue Jun 19 20:35:16 CEST 2007
When running pylint on a turbogears project, pylint can't find the
class methods for automatic SQLObject methods. The general workaround
for this is to ignore class method errors, but these can be very
useful, and are not something one wants to disable lightly. I've made
a patch for a tg mode, in the same vein as the zope mode, whereby
certain classes are ignored for method checking:
*** typecheck.py Tue Jun 19 11:27:53 2007
--- typecheck.py.tg Tue Jun 19 11:21:24 2007
***************
*** 68,77 ****
--- 68,89 ----
'metavar' : '<members names>',
'help' : 'List of members which are usually get
through \
zope\'s acquisition mecanism and so shouldn\'t trigger E0201 when
accessed \
(need zope=yes to be considered).'}
),
+ ('tg',
+ {'default' : False, 'type' : 'yn', 'metavar':
'<y_or_n>',
+ 'help' : 'When tg mode is activated, ignore class
names in\
+ ignored_classes.'}
+ ),
+ ('ignored_classes',
+ {'default' : (
+ 'SQLObject',),
+ 'type' : 'csv',
+ 'metavar' : '<members names>',
+ 'help' : 'List of classes to be ignored when tg is
enabled.'}
+ ),
)
def visit_getattr(self, node):
"""check that the accessed attribute exists
***************
*** 101,110 ****
--- 113,127 ----
continue
# XXX "super" / metaclass call
if is_super(owner) or getattr(owner, 'type', None) ==
'metaclass':
continue
name = getattr(owner, 'name', 'None')
+
+ # if we're running in tg mode, skip class names in
ignored_classes
+ if self.config.tg and name in self.config.ignored_classes:
+ continue
+
if ignoremim and name[-5:].lower() == 'mixin':
continue
try:
owner.getattr(node.attrname)
except AttributeError:
It seems to work well for me.
(it should be noted that I've been unable to subscribe to the mailing
list, likely due to the corporate firewall)
Thanks for a great tool,
-twb
**************************************
Thomas W. Barr, tbarr at aero.org
The Aerospace Corporation
Computer Systems Research Division, High Performance Computing
**************************************
More information about the Python-Projects
mailing list