logilab-astng #2477 false positive on class derivating from base types [open]
Dans la version en cours de dev de pylint, si on analyse tact.domain.physic, pylint dit (entre autres): E: 78:UnitMixIn.getKUnitStr: Instance of 'unit' has no 'unitStr' member La ligne 78, c'est le return de getKUnitStr ci dessous: class unit(float): def __new__(cls, coeff=1., unitStr=''): inst = float.__new__(cls, coeff) inst.unitStr = unitStr or cls.__name__ CONVERSION_DICT[inst.unitStr] = inst return inst def __call__(self, siValue=1.): return self * siValue liter = unit(1., 'L') second = unit(1., 's') pulse = unit(1., 'Pulse') class UnitMixIn(Serializable): def __init__(self): self.volumeUnit = liter self.timeUnit = second self._flowUnit = (liter, second) self.kUnit = (pulse, liter) def getKUnitStr(self): pulseUnit, volumeUnit = self.kUnit return '%s / %s' % (pulseUnit.unitStr, volumeUnit.unitStr) Je pense que c'est un exemple (presque) minimal pour reproduire le problème. | |
priority | normal |
---|---|
type | bug |
done in | <not specified> |
load | 0.500 |
load left | 0.500 |
closed by | <not specified> |
similar entities
- pylint #9223 __future__ module does not contain real symbols
- logilab-astng #2451 find a way to help inferences in some cases
- logilab-astng #905 proper metaclass support
- logilab-astng #3158 use logging to allow pylint to get (at least) inference error information
- pylint #4593 pylint complains when initializing attribute via property()
[see all]
Comments
-
2009/11/23 18:25, written by sthenault
add commentthe pb is that __new__ should be handled specificaly so that in the example above, 'cls' is seen as the 'unit' cls and 'inst' a 'unit' instance.