add support of 'six.with_metaclass' #841
Conversation
|
flagged pylint issues are related to very recent merge of pylint-dev/pylint#3782 with fix of issue pylint-dev/pylint#3468 |
|
@fmigneault please pay attention to #713 (comment). This code from enum import Enum, EnumMeta
import six
class FooMeta(EnumMeta):
pass
class Foo(six.with_metaclass(FooMeta, Enum)):
bar = 1produces error with this fix: |
|
@tkukushkin The problem in is that after Therefore there is no more reference to |
|
@fmigneault I completely understand the cause of this problem and I don't know not hacky solutions and PCManticore did not respond to my comment. That's why I didn't make pull request with this transform. |
PCManticore
left a comment
There was a problem hiding this comment.
Overall the change looks good, but we need to drop the inference check from the predicate function as it can result in weird inference bugs.
astroid/brain/brain_six.py
Outdated
| if not isinstance(base, nodes.Call): | ||
| return False | ||
| try: | ||
| func = next(base.func.infer()) |
There was a problem hiding this comment.
Unfortunately we cannot use inference in predicate functions. Here you would need o unpack the arguments for checking if they refer to six.with_metaclass or not (by unpacking I mean either checking explicitly for Name or Attribute instances that match against six.with_metaclass)
There was a problem hiding this comment.
Should be good now. Let me know if it is still not what like you meant.
3138597 to
4e1fd95
Compare
|
Thanks for the PR @fmigneault ! |
Steps
Description
Fixes issue #713 by providing corresponding transform and unit tests.
Type of Changes
Related Issue
Closes #713