Skip to content

Pylint does not detect a missing relative import when an absolute import with the same name is present #500

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

Closed
pylint-bot opened this issue Mar 24, 2015 · 1 comment
Labels

Comments

@pylint-bot
Copy link

Originally reported by: Ignacio Rossi (BitBucket: pignacio, GitHub: @pignacio?)


If there's no mock module at the same level, the following code, when linted, produces an expected "Unable to import 'mock'" error

#!python

from .mock import patch

patch('a.b')

But, if the mock library is present (via pip install mock), the error dissapears, even though the relative import keeps failing.

Tested on a clean virtualenv using latest version. Here's my pip freeze

argparse==1.2.1
astroid==1.3.6
logilab-common==0.63.2
pylint==1.4.3
six==1.9.0
wsgiref==0.1.2

@pylint-bot
Copy link
Author

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Thanks for the report and sorry for the delay.

Using the latest astroid tip https://bitbucket.org/logilab/astroid/commits/e907876a292f4ee009d65505e610dbc8c7956e30, the output now looks like this:

#!python

C:  3, 0: Final newline missing (missing-final-newline)
C:  1, 0: Missing module docstring (missing-docstring)
E:  1, 0: Unable to import 'mock' (import-error)

I'll update the import-error message to show that's in fact '.mock'.

msuozzo pushed a commit to msuozzo/pylint that referenced this issue Feb 18, 2022
msuozzo pushed a commit to msuozzo/pylint that referenced this issue Feb 18, 2022
~~Based on branch for PR pylint-dev#500 -- I will rebase after that PR merges.~~

Closes pylint-dev#367.
    
Supersedes PR pylint-dev#497.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant