from
Marc 'BlackJack' Rintsch <marc at rintsch dot de>
to
Python-Projects <python-projects at lists dot logilab dot org>
subject
[Python-projects] 1 Bug(?) / 1 Code Smell / 1 Feature Request
date
Hi,2005/02/08 08:33
First let me tell you that I like PyLint very much. It's a great tool
to check for common mistakes, code conventions and code smells.
I think there's a bug with meta classes. The following code lets
PyLint report an error::
class Meta(type):
def __init__(mcs, name, bases, dictionary):
super(Meta, mcs).__init__(name, bases, dictionary)
print mcs._meta_args
delattr(mcs, '_meta_args')
class Test(object):
__metaclass__ = Meta
_meta_args = ('foo', 'bar')
The error is reported at the ``print`` line and says that `_meta_args`
is not defined. I guess it's because the attribute is deleted after
the meta class used it.
++++
Defining only static and/or class methods in a class definition is
IMHO a code smell because it suspiciosly looks like Java code and
those methods should be functions at module level instead::
class Static:
def static_method():
pass
static_method = staticmethod(static_method)
def class_method(cls):
pass
class_method = classmethod(class_method)
I'm not so sure about class methods but a class with just static
methods should trigger a warning.
++++
Last but not least a feature request. When I started with Python I
didn't get the "a (logical) line ends if all opened parantheses are
closed" part of the language specs and often used '\' characters to
break long lines. Now I prefer the solution with braces and it would
be nice to have an optional warning for line continuations with '\'.
It's easy to do with ``find`` and ``grep`` but then it's not part of
the rating.
Ciao,
Marc 'BlackJack' Rintsch
--
A man should never be ashamed to own he has been in the wrong,
which is saying, in other words, that he is wiser today
than he was yesterday. -- Jonathan Swift
