Anvil Community Forum

[BETA] Don't add unwanted imports

The new editor appears to add import lines to forms when it sees its ‘standard’ imports are missing.

e.g. it will add:

import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables

Could it please not do that? (or at least have the option for me to disable it)? I take some care over how my imports are defined and I don’t like having that overridden.

2 Likes

In my case, none of the editors imported after I initially removed.

However, I think this should really be a configuration. I hate to have to remove all those imports in every form, module and package I create in the client code since I don’t use server code in the client code.

I think the initial code for each form/module/package should be user-defined (except the necessary designer imports for forms of course).

1 Like

Just linking this related request:

This seems to have been implemented, :grinning: with an option in the Beta editor Accounts menu:

5 Likes

That’s a rather big stick. It’d be nice to be able to specify per service if it should be auto imported or not. For example, I generally do want the User service imported, but generally not the Google related packages (since I usually have the Google service only for logging in with Google via the User service).

3 Likes

This is awesome, but added a lot of problems to me by default. I hadn’t changed the new sneaky option to No yet and when I created a new module, not only it imported the services to the new module, but also to EVERY OTHER FORM/MODULE IN THE APP.

I just noticed when I was commiting. :cry:
Had to go rollback, disable the option and redo everything that I did (fortunately, it wasn’t much work).

That would be best. Or maybe just a text area where you could type all the auto imports you want.

And only apply to new forms & modules :wink:

1 Like