Thank you very much for your swift response and for suggesting pyflakes.

My question aimed at a different angle.  Let me explain it again, with a
concrete example:

Assume my file `pkg/message_decoder.py` defines a function `decode_message`.
I am now writing another file `pkg/api.py` which contains (among others)
the following line:

    message = decode_message(requests.get(api_url,
data=request_data).json())

For this to work, the Declarations of the `api.py` file need to contain at
least the following two lines:

    import requests
    from pkg.message_decoder import decode_message

I am looking for a solution to create these two import statements
automatically --- without me remembering the sources that define each
symbol.

I imagine myself editing just a clone of the node (a child of @clean
pkg/api.py) that defines the above line `message = ...`.
Pyflakes will mark the two symbols `decode_message` and `requests` as
undefined --- and I want to press some button and have the right import
lines added to the right Declarations node.

The problems I want to solve are:
* I don't want to remember the sources of each feature.
* I don't want to trace back the right Declaration node to add it to.

So my question is: Is there a good solution for this in leo --- and if not,
what do you do when you add code that requires additional imports?

Yaakov




On Mon, Feb 17, 2020 at 3:30 PM Edward K. Ream <[email protected]> wrote:

>
>
> On Mon, Feb 17, 2020 at 7:20 AM Yaakov Belch <[email protected]>
> wrote:
>
> Hi I am starting to use Leo for programming --- and wonder whether it
>> comes with some feature (like importmagic) to add python import statements
>> as needed to the code?
>>
>> In other words -- do you remember the file paths of all your features and
>> write out the import statements for each new file by hand or do you have
>> some tool to help you with that?
>>
>
> I'm not sure I understand your question. However, I always enable pyflakes
> on write, and pyflakes will warn about *any* undefined symbol.
>
> If you are a python programmer, then you definitely should set:
>
> @bool run-pyflakes-on-write = True
>
> pyflakes catches roughly 95% of my programming blunders.
>
> Edward
>
> --
> 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/CAMF8tS2oN5NsFZOVLGhkt6sCQf3gGkYv2NDOr5vSo%2B0PFD40ww%40mail.gmail.com
> <https://groups.google.com/d/msgid/leo-editor/CAMF8tS2oN5NsFZOVLGhkt6sCQf3gGkYv2NDOr5vSo%2B0PFD40ww%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAHWiE3VLXPz7WcuTrC1JBAOWQYHDqwT4fRnCQ%2BTav_1Dkz%3DNDg%40mail.gmail.com.

Reply via email to