Spurious no-member
errors with modules named builtins
on py3
#3327
Labels
False Positive 🦟
A message is emitted but nothing is wrong with the code
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
pylint gives incorrect
no-member
errors when checking a file that does afrom
-import of a module named "builtins" in python3 and then accesses any name that are not attributes ofdict
types. (My guess is that this also would have happened in python2 with modules named__builtin__
, but that's much less likely to happen in IRL code than a module calledfoopkg.builtins
.)This does not occur when doing
import foopkg.builtins as builtins
, only when doingfrom foopkg import builtins
. It does not matter whether the module is aliased to some other name (eg,... as builtins_mod
).Steps to reproduce
Commands to set up a test case:
Pylint run & output:
This does not occur with pylint 1.6.5, but does occur with 1.7.6 (with python3.6, 1.7.6 does not work with python3.7 (#2241)). This makes it similar to #1606, but I don't think this is a duplicate of that issue - this occurs with any (even trivial, as shown above) modules named
builtins
, and is unrelated to anything weird thatfuture.builtins
is doing, so the fix suggested in that issue wouldn't resolve this.I have set up a test case in AdamG@f2e7019 that is currently failing, but should work as a regression test once the underlying issue is fixed.
Current behavior
When doing a from-import, gives an error on access of
builtins_mod.foo
, even though it exists in that module.The error message always indicates that pylint thinks that the
builtins
object is adict
, which points to checkers.utils.is_builtin() being somehow involved. I tried a few things in VariablesChecker and TypeChecker, but nothing seemed to make a difference; i'm not familiar enough with this codebase/astroid to get much further.Expected behavior
It should not give the incorrect no-member error. It certainly shouldn't conditionally occur based on the name of the imported module.
pylint --version output
see above
The text was updated successfully, but these errors were encountered: