Skip to content
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

Spurious no-name-in-module with future.builtins.disabled on Python 3 with pylint 1.7.0+ #1606

Closed
posita opened this issue Aug 2, 2017 · 6 comments
Labels
Bug 🪲 Lib specific 💅 This affect the code from a particular library

Comments

@posita
Copy link

posita commented Aug 2, 2017

Test file:

"""
test_disabled_import.py
"""

from future.builtins.disabled import *  # pylint: disable=redefined-builtin,unused-wildcard-import,wildcard-import

Python 2 works as expected:

$ python -c 'from future.builtins.disabled import * ; import pprint ; pprint.pprint(dir())'
['StandardError',
 '__builtins__',
 '__doc__',
 '__name__',
 '__package__',
 'apply',
 'chr',
 'cmp',
 'coerce',
 'execfile',
 'file',
 'input',
 'long',
 'pprint',
 'raw_input',
 'reduce',
 'reload',
 'unicode',
 'xrange']
$ pylint --version
pylint 1.7.2,
astroid 1.5.3
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
$ pylint --rcfile=/dev/null test_disabled_import.py

------------------------------------
Your code has been rated at 10.00/10

Python 3 gets confused:

$ python -c 'from future.builtins.disabled import * ; import pprint ; pprint.pprint(dir())'
['__annotations__',
 '__builtins__',
 '__doc__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 'pprint']
$ pylint --version
pylint 1.7.2,
astroid 1.5.3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
$ pylint --rcfile=/dev/null test_disabled_import.py
************* Module test_disabled_import
E:  5, 0: No name 'disabled' in module 'dict' (no-name-in-module)

----------------------------------------------------------------------
Your code has been rated at -15.00/10 (previous run: 10.00/10, -25.00)

Possibly related to #1536?

@posita
Copy link
Author

posita commented Aug 2, 2017

Note this is new to 1.7.0+:

$ pylint --version
pylint 1.7.0,
astroid 1.5.3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
$ pylint --rcfile=/dev/null test_disabled_import.py
************* Module test_disabled_import
E:  5, 0: No name 'disabled' in module 'dict' (no-name-in-module)

-------------------------------------
Your code has been rated at -40.00/10

This does not happen with 1.6.5:

$ pylint --version
pylint 1.6.5,
astroid 1.4.9
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
$ pylint --reports=n --rcfile=/dev/null test_disabled_import.py
************* Module test_disabled_import
I:  5, 0: Locally disabling redefined-builtin (W0622) (locally-disabled)
I:  5, 0: Locally disabling unused-wildcard-import (W0614) (locally-disabled)
I:  5, 0: Locally disabling wildcard-import (W0401) (locally-disabled)

@posita posita changed the title Spurious no-name-in-module with future.builtins.disabled on Python3 Spurious no-name-in-module with future.builtins.disabled on Python3 with 1.7.0+ Aug 2, 2017
@posita posita changed the title Spurious no-name-in-module with future.builtins.disabled on Python3 with 1.7.0+ Spurious no-name-in-module with future.builtins.disabled on Python 3 with pylint 1.7.0+ Aug 2, 2017
@posita
Copy link
Author

posita commented Aug 2, 2017

Note, this also appears to happen with Python 3.5 (not just 3.6):

$ pylint --version
pylint 1.7.2,
astroid 1.5.3
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 08:49:46)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
$ pylint --rcfile=/dev/null test_disabled_import.py
************* Module test_disabled_import
E:  5, 0: Unable to import 'future.builtins.disabled' (import-error)

----------------------------------------------------------------------
Your code has been rated at -40.00/10 (previous run: -40.00/10, +0.00)

So this is probably not related to #1072. (See also this comment.)

@PCManticore
Copy link
Contributor

I presume we'll need an astroid brain plugin to understand what future is doing that makes disabled accessible: https://github.com/PythonCharmers/python-future/blob/master/src/builtins/__init__.py.

@rawrgulmuffins
Copy link

Link to astroid brain plugin docs?

@PCManticore
Copy link
Contributor

We don't have great docs for it, it's best to just poke the code in the brain directory to see how to write the plugins: https://github.com/PyCQA/astroid/tree/master/astroid/brain

@Pierre-Sassoulas Pierre-Sassoulas added the Lib specific 💅 This affect the code from a particular library label Jun 29, 2022
@Pierre-Sassoulas
Copy link
Member

Closing as it's lib specific and with python 2 being dead and buried it's unlikely that this will ever attract the necessary attention to get fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Lib specific 💅 This affect the code from a particular library
Projects
None yet
Development

No branches or pull requests

4 participants