Open pylint-bot opened 10 years ago
Original comment by the mulhern (BitBucket: the_mulhern):
I'm adding another pylint/six bad interaction.
Given the following:
#!python
import abc
from six import with_metaclass
class Junk(with_metaclass(abc.ABCMeta, object)):
def __init__(self):
super(Junk, self).__init__()
pylint reports
"E: 6, 4: Use of super on an old style class (super-on-old-class)"
Essentially, analyses can not detect that Junk extends object, and interprets the definition as an old style class.
This can be fixed by using add_metaclass instead of with_metaclass. Evidently, with_metaclass concocts a secret subclass from which Junk inherits directly so that it inherits from object only indirectly while add_metaclass does not.
There is a chance that this is a six bug, and not a pylint bug at all.
In any case, it does seem to have a workaround in most cases.
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):
Which version? With Pylint 1.2 and astroid from the tip I get no super-on-old-class, both Python 2 and 3.
Original comment by Maxim Syabro (BitBucket: syabro, GitHub: @syabro?):
With same behavior I can't use Serializer.data but it's defined in BaseSerializer
class Serializer(six.with_metaclass(SerializerMetaclass, BaseSerializer)):
pass
Original comment by Brett Cannon (BitBucket: brettcannon, GitHub: @brettcannon?):
Are there any plans to address the issue with overriding built-ins that have changed in Python 3?
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):
No, the only plan I have, for now, is fixing the with_metaclass
false positive. As always, pull requests are appreciated. :-)
Original comment by Brett Cannon (BitBucket: brettcannon, GitHub: @brettcannon?):
=) I figured as much. I figure the check could be modified to not check for a key list of changed built-ins while simultaneously checking if they are not overridden in python3.
Original comment by Brett Cannon (BitBucket: brettcannon, GitHub: @brettcannon?):
So how would you like to see the warning triggered when a built-in is replaced? This is an issue in Python 2/3 code as filter, map, zip, round, range, input, and open are all different in Python 3, so it's legitimate to replace them with the Python 3 version to get consistency.
Do you want to whitelist certain built-ins to not be warned for? Or is there some way to have a checker be tweaked based on another checker being on (i.e. the built-in replacement checker not checking whitelisted built-ins when another checker that warns against dangerous use of the built-ins is active)? Or are people simply expected to silence this warning manually?
Original comment by Benoit C (BitBucket: dzen, GitHub: @dzen?):
I think pylint should be aware of some specificities in six: importing from moves raises:
"from six.moves.urllib.error import URLError" raises no-name-in-module
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):
Try with the latest version from the repository, we have special support for six.moves. It will be released soon, as pylint 1.5.
Originally reported by: Thomas Grainger (BitBucket: graingert, GitHub: @graingert?)
When using
from six.moves import range
pylint complains that built-ins are being overridden.In actual fact it should complain that the built-in range is used rather than the forward-looking six.moves version.
https://bitbucket.org/logilab/pylint.org/issue/4