alecthomas / importmagic

A Python library for finding unresolved symbols in Python code, and the corresponding imports
BSD 2-Clause "Simplified" License
120 stars 20 forks source link

from datetime import datetime is never given for datetime #41

Open paradoxxxzero opened 7 years ago

paradoxxxzero commented 7 years ago

I narrowed it down to the fixup method but no real succes in fixing it, except from not calling the method when the symbol is in the path https://github.com/alecthomas/importmagic/compare/master...paradoxxxzero:master but this seems hackish and would not work for module in module in module all with the same name...

Any thoughts?

alecthomas commented 7 years ago

Can you check your index to see if that symbol is available?

paradoxxxzero commented 7 years ago

Yes it is, all works fine until the fixup method removes the variable because it's the same as the module, which is what we want for datetime.datetime but not for datetime. In both of these cases, the fixup method is called twice, once with datetime, None and once with datetime, datetime. However it always returns datetime, None which is wrong for the latter case.

I hope I'm being clear enough :)

Btw Thanks for this awesome project, that I now use daily in http://github.com/Kozea/wdb and Atom https://github.com/paradoxxxzero/atom-python-import-magic

Le sam. 17 sept. 2016 à 09:24, Alec Thomas notifications@github.com a écrit :

Can you check your index to see if that symbol is available?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alecthomas/importmagic/issues/41#issuecomment-247754928, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQjKEcsd_7zq23B1YoJWDJsVO0KBgb8ks5qq5WkgaJpZM4J_Gyf .

kbauer commented 6 years ago

Ran into the same issue today with pprint.pprint, which I normally import as

from pprint import pprint

Possibly related: For sin, the completing from numpy.ma.core import sin is offered, but not the more sensible from numpy import sin.