Structuring project for IDE, static analysis, and testing

I’m new to Anvil (and loving it) and a long time Python developer. The built in Anvil editor is great. But, I’m curious how people structure their projects and dev workflow to be able to use:

  • static analysis tools (type checking, linting, auto-formatting)
  • traditional IDEs like PyCharm or VS Code (for running, debugging, autocomplete, refactoring, AI assistance, running tests locally)
  • automated testing

Any suggestions, links to docs, forum posts, or example projects would be great! I’m assuming the GitHub integration and Uplink could be used to make some progress, but I’m curious to hear what people are actually using.

Welcome!

The Anvil IDE has Ruff built in for linting and auto-formatting (You can Press Ctrl+Alt+M for checking linting messages and Shift+Alt+F for auto-formatting the current file)

You can use your own IDE locally by git cloning it:

For testing, here are some posts:

2 Likes

Thanks, Duncan! Excellent info and links. I appreciate you pulling those together!

1 Like

I’m excited, so I had to share…

TIL I could run my Anvil server code (after cloning the project locally) on my local laptop (via server uplink) and any public UI would automatically use my locally-running server code to serve requests! This allowed me to set breakpoints in server code and inspect variables while clicking through the UI! I can obviously do this with the very nice Anvil IDE, but sometimes it is helpful to use local tools.

I then wrote a simple script locally that called a few server functions and also ran it locally via uplink. So I was able to run both server code and test script locally using uplink, enabling me to use local IDEs, interactive debuggers, etc. I can see how I could easily use this setup to develop locally and run both the backend code and automated tests locally, which is great!

This style of setup was kind of hinted at in the links above, but seeing it run live really helped solidify in my mind how flexible the uplink tech is! I was surprised that running the UI from the web interface automatically used my backend server that was running locally! Among other things, this enables the local development workflow described above.

Note: My project is currently very simple and doesn’t make use of any 3rd party dependencies. I’m just using a simple local venv for the python interpreter.

Details:
For those curious, this concept was “unlocked” for me when I cloned my project locally and read the contents of the __init__.py file at the top of the project directory. It mentioned you could run server-side code on your own machine with:

pip install anvil-uplink  
python -m anvil.run_app_via_uplink YourAppPackageName

Lovin’ it!

1 Like