← Back to team overview

nova team mailing list archive

Re: pylint and methods that could be functions

 

Ah, yeah, that's a good suggestion.


On Aug 10, 2010, at 4:31 PM, Monty Taylor wrote:

> On 08/10/2010 04:26 PM, Chris Behrens wrote:
>>
>> All,
>>
>> What's the preference on methods that could be functions?   pylint is
>> currently complaining on any class method that doesn't access 'self',
>> meaning that the method doesn't necessarily need to be a part of a
>> class.   I'm going back and forth on it.  I tend to think it makes
>> sense to keep some things as a part of a class for organizational
>> purposes... but I don't know.
>
> I like inclusion for org purposes... but:
>
>> Some examples are in nova/compute/model.py's InstanceDirectory.  Most
>> of the methods don't need to be a part of the class, but I can see
>> where it's nice to organize it all that way...   If we want to keep
>> it, I think we may want to make pylint ignore this code?
>
> Or perhaps just remove the self arg and make it a static method:
>
> class Foo:
>
>  @staticmethod
>  def bar(a, b):
>    # isn't really part of the class, but is organizationally.
>
>
> Monty




Follow ups

References