Agent put import at bottom of form code

Hardly a showstopper, but the built in Codex agent put an import at the end of the code on a form. I don’t care, but anvil underlines it in yellow and suggest moving it.

from ._anvil_designer import AppMasterlistTemplate
from anvil import *
import anvil.server

class AppMasterlist(AppMasterlistTemplate):
  def __init__(self, **properties):
    super().__init__(**properties)
    # loads of form code here ...

then right down the bottom :

from .AppMasterlistEdit import AppMasterlistEdit

Honestly, I can’t imagine a less important oddity to look at …

2 Likes

David,

I saw your other post about AGENTS.md . This is a good reason to use it. You can tell Codex to put imports at the top of each Python file. Or, if your Anvil app already has import-sorting rules in pyproject.toml or ruff.toml , you can tell Codex to follow those rules. Either way, you can ask Codex to add the instruction to AGENTS.md for you.

2 Likes