Imports - local vscode vs cloud

What I’m trying to do:
I’m trying to find the best way to import a module from the client_code that works both in a local vscode environment, and on the cloud version of anvil.

What I’ve tried and works, but is not very convenient

try:
  from ..models import CustomClass
except ImportError:
  from ...client_code.models import CustomClass 

Is there a more elegant way to tackle this issue?

I assume you are trying this for some testing purpose? I have seen similar things when I played around with testing client code locally and that was about the best I could come up with. The only difference being that I used if-else instead of try-except.

Maybe this will help: Using PyCharm for development and testing

2 Likes

Thank you very much for this! Couldn’t make it work just yet, but there’s some super useful info in there!