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

ranking within 3rd party libraries? #12

Open ChillarAnand opened 9 years ago

ChillarAnand commented 9 years ago

when working with django, django & lot of 3rd packages for django have same models, views e.t.c

If i try to import models.Model or User it shows import options in the following order

im2

im

Is it possible to move the django imports to top? Can we have a user based ranking or caching the imported imports & ranking them a bit higher? Or is there any other option?

birkenfeld commented 9 years ago

That's certainly possible. Currently rankings are assigned at parse time, but I can imagine adding after-the-fact reranking of modules.

In the context of elpy, elpy would inform the backend about the user choice, and the package/module selected by the user would get a tiny ranking increment.

The problem is how to persist that ranking. Sooner or later we'll have to cache the index somewhere, but it falls on elpy to manage that per project.