pychecker - sets.Set need to be overridden

I

Istvan Albert

Hello all,

if I have this code:

import sets

class Foo:
x = sets.Set()

then pychecker says:

test.py:4: Methods (__cmp__, __hash__) in sets.Set need to be overridden in a subclass

I don't get this message. What is it trying to say, and why?

Istvan.
 
W

wittempj

mport sets

class Foo:
def __init__(self):
self.x = sets.Set()

x = Foo()
print x, getattr(x, 'x')

gives for me:
<__main__.Foo instance at 0x00C578A0> Set([])
on 2.4. on WinXP. What environment do you run in?
 
I

Istvan Albert

<__main__.Foo instance at 0x00C578A0> Set([])
on 2.4. on WinXP. What environment do you run in?

I'm running it on cygwin,

but still don't get it, why the warning?

Istvan.
 
P

Peter Otten

Istvan said:
if I have this code:

import sets

class Foo:
x = sets.Set()

then pychecker says:

test.py:4: Methods (__cmp__, __hash__) in sets.Set need to be overridden
in a subclass

I don't get this message. What is it trying to say, and why?

The minimal example is actually

import sets
sets.Set()

The Set class has implementations for __cmp__() and __hash__() that
unconditionally raise an exception. pychecker assumes that these methods
are "abstract", i. e. meant to be overriden by a subclass, and warns that
you are instantiating an abstract base class, while the intention of the
Set class author was to make Sets "uncomparable" and unhashable by
overriding the corresponding superclass methods.

Peter
 
W

wittempj

I don't know pychecker, maybe there's something wrong with it as your
code seems valid to me.
 
I

Istvan Albert

Peter said:
The Set class has implementations for __cmp__() and __hash__() that
unconditionally raise an exception. pychecker assumes that these methods
are "abstract", i. e. meant to be overriden by a subclass, and warns that
you are instantiating an abstract base class, while the intention of the

I see. Thanks!

Istvan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,216
Messages
2,571,116
Members
47,720
Latest member
mohdkaif002

Latest Threads

Top