Repository navigation
[tools] Enable additional linting rules - #11110
Conversation
The `dict.has_key` method was removed in Python 3.1 with the recommendation to, "use the `in` operator instead." https://docs.python.org/3.1/whatsnew/3.0.html#builtins
Hexcles
left a comment
There was a problem hiding this comment.
Custom has_key methods are defined in wptrunner/wptrunner/wptmanifest/backends/{conditional,static}.py
which is why unit tests are failing with your changes. The methods probably need to be renamed to the magic __contains__.
|
Thanks for the tip, @Hexcles! Unfortunately, enabling this linting option might take a little more work. That's because the "conditional" def __contains__(self, key):
return key in self._dataAnd its semantics are distinct from those of the custom def has_key(self, key):
for node in [self, self.root]:
if key in node._data:
return True
return FalseThere may be a case to be made against an API where What do you think? |
|
We should probably rename That said, I haven't looked too closely at the related code. If you're not sure what to do, then we can always make a smaller step each time (i.e. abandon the second and third commits for now). |
|
@jgraham objected to renaming |
|
@gsnedders In that case, we should definitely proceed with that change in a separate patch. Thanks for letting us know! @jgraham In can't find anything about your objection on GitHub or the #testing IRC logs. Would you mind re-iterating here? @Hexcles I've reverted the commits related to that rule. This should be good to go now. |
|
Thanks, @gsnedders! |
|
Oh and @Hexcles of course :) |
This change is