Require python imports to be modules

Viewed 1007

The Google Style Guide for python states that one should: "Use imports for packages and modules only."

https://google.github.io/styleguide/pyguide.html#Imports

Is there a tool that flags violations of this suggestion?

Pylint does NOT do it. For example, following: Is there a tool to lint Python based on the Google style guide?

Creating a test.py the violates the guideline (exists is a function, not a module):

"""Test file for pylint"""
from os.path import exists

exists('/home')

Then, running pylint with the rc file does just fine:

$ pylint --rcfile=googlecl-pylint.rc -r n -s n  test.py
$ echo $?
0

Searching through the possible codes: http://pylint-messages.wikidot.com/all-codes, I don't see anything that looks like it would warn against this.

I have also not seen anything in pep8 or pyflakes that will catch this.

1 Answers
Related