Pylint false positives
On 2018-08-14 04:58 AM, Frank Millman wrote:
> "D'Arcy Cain"? wrote in message
>> I am also getting a funny smell from your description.? Are you sure
>> that you need to redefine the methods?? Perhaps you just need to define
>> some class variables and use one method.? You can also define your own
>> method and call the classA method inside it for common functionality.
> As an example, I have a master class defining a unit of data (i.e. the
> value of a column) retrieved from a database. I have separate
> sub-classes for each data type - text, integer, date, etc. To ensure
> that a value is valid before storing it as an instance attribute, I call
> a method called 'check_value'. The details of check_value vary according
> to the data type, but that is transparent to the piece of code that
> calls check_value().
DATATYPE = None # Or default type
def check_value(self, v)
if not isinstance(v, self.DATATYPE):
raise RuntimeError("Invalid data type for '%s'" % v)
DATATYPE = int
Very simplistic and untested but does that give you any ideas?
Hopefully your email client doesn't mess up the formatting. You can
fill out check_value to do more than simply check the the type matches
and you can also do further checks based on the type. Also, you can
have more than one sub-class doing the same check without having to cut
and paste code from another class.
D'Arcy J.M. Cain
Vybe Networks Inc.
IM:darcy at Vex.Net VoIP: sip:darcy at VybeNetworks.com