> But first:  Why are automatic imports important for me?  For me, editing 
> import statements whenever a new dependency is added to a module is a "deep 
> interruption" of my work flow.  I really just want to use a function --- 
> but I have to (1) remember or research where exactly that function was 
> defined.  I have to (2) jump to a different location to edit the import 
> statement and I have to (3) jump back to the place where I was working.
>

For #1, I find it important to remember what the module has the function. I 
wouldn't want to get *os.path *confused with *foorbar.null.path. *When I 
don't like the extra typing I use the idiom *"from foobar import null as 
fbn"* and then use it as *"fbn.path".*

For #2 and thus #3: just skip them! When I'm in flow and need a new module 
I just "import foo" right where I am, inside the function even. Later, 
after the thing is working well enough, I move the import where it belongs. 
There are probably subtle (or not so subtle!) scenarios where this pattern 
causes problems but so far it hasn't happened to me.

I'm not arguing against an auto-import feature, just answering the "what do 
you do?" part of the question.

-matt
I saw a python utilty somewhere on pypi.org that handled 
move-imports-automatically as part of a code linting process but didn't 
feel the need to follow up on it. I see an active feature request for Black 
to move and order imports: https://github.com/psf/black/issues/333. A quick 
read of the comments seems to indicate it might be forthcoming soon. If it 
does, then I expect Leo to be able to use it straightforwardly.



-matt

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/554901b5-a249-49ae-9602-c806db894133%40googlegroups.com.

Reply via email to