QoL idea for importing

Hello, just an idea :light_bulb: that i think could help.

If user would like to import an type, but forgot where is is,
something like this could help:

import Variant from ..? # (..? is not an thing user do, it just means suggestions)
import ThatType from  #<- Suggestions 

 
Could mojo have this ?

Because if user would like to import variant for example,
there is no way to currently help user i think:

from ? import Variant
     ^ Where

 

So two ways, depending on starting point:

  1. from utils import Variant
  2. import Variant from utils
1 Like

While I like it from an ergonomics perspective, I think this would be prone to breaking in large codebases, and is also probably going to be horrible for an LSP to deal with.

1 Like

Python/Guido deliberately chose the “from X import Y” syntax instead of “import Y from X”, and Mojo should probably just stick with it for the sake of consistency and familiarity. We don’t want to create unnecessary headaches for people coming from Python.

Sorry @owenhilyard and @Nick , i explained it wrong.

What i mean is not adding ..?
but letting mojo suggest to the user something,
so that the user gets unstuck:

import Vectorize from 

Here user would like to vectorize,
but don’t know how to get it !

What will practically happen in this order is that this will make the LSP kick everyone’s CPUs on as they try to type an import statement. It’s probably better to make this an LSP action which inserts the import line for a type which wasn’t found.