-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect inference of ancestors of Enum class with six.with_metaclass #713
Comments
After some debug I see, that |
Maybe need to register transform for P.S.: |
Possible implementation: def _looks_like_nested_from_six_with_metaclass(node):
if len(node.bases) != 1:
return False
base = node.bases[0]
if not isinstance(base, Call):
return False
call = base
try:
func = next(call.func.infer())
except InferenceError:
return False
return func.qname() == 'six.with_metaclass'
def _transform_six_with_metaclass(node):
call = node.bases[0]
node._metaclass = call.args[0]
node.bases = call.args[1:]
MANAGER.register_transform(
nodes.ClassDef,
_transform_six_with_metaclass,
_looks_like_nested_from_six_with_metaclass,
) |
@tkukushkin Just managed to check your issue. I believe it makes sense, would you be able to submit a PR with that transform, tests and all the relevant boilerplate? Let me know if you need any help with that. |
@PCManticore, I have an issue, that after removing |
Any update on this? I'm experiencing the same issue |
In earlier version (eg
|
@PCManticore, @fmigneault original issue is reproduced again after #893. |
Steps to reproduce
Current behavior
Prints
[<ClassDef.NoneType l.0 at 0x102bb4d68>, <ClassDef.object l.0 at 0x102bbe1d0>]
Expected behavior
Prints
[<ClassDef.Enum l.10 at 0x10d0617b8>, <ClassDef.object l.0 at 0x10c4650f0>]
With another simple example without enums works ok:
Prints:
[<ClassDef.BaseFoo l.6 at 0x1091531d0>, <ClassDef.object l.0 at 0x10853d128>]
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output2.3.2
This behaviour breaks pylint with exception:
The text was updated successfully, but these errors were encountered: