IDE Autocomplete stops working in server file in python 3.10 env from walrus operator

What I’m trying to do:
Code in the Anvil IDE in a file >400 lines and use the autocomplete

What I’ve tried and what’s not working:
In all my client and server files smaller than 400 lines of code, I can use the autocomplete just fine, but in a file I have that is over 400 lines, the autocomplete just stops working. This applies to both client and server files.

I know this isn’t because of bad syntax since the file that isn’t using the autocomplete runs perfectly fin.

Is this a bug or a known limitation of the online IDE?

Hi @duncan_richards12,

There isn’t a design limitation at 400 lines! Could you provide a clone link for an app that demonstrates the problem you’re having?

Its a bit of a big app and I would rather not have it all hang out there since its not just a hobby project, would it be better to email the support email the clone link or email the specific file?

If an ordinary file of >400 lines doesn’t replicate the issue, then that does lead to a suspicion that there’s something funny about your code in particular. If you’ve tried a publicly-shareable replication and that doesn’t work, drop a link to your app (not a clone link, we’ll just use Magic Admin Powers) to support@anvil.works.

My experience is that autocomplete stops working as soon as there is a syntax error elsewhere in the file. No matter how long or short the file, it starts working again after the error is fixed. I have a 1566-line module that behaves exactly this way, so length does not appear to be the issue.

That said, I have a 510-line file where syntax highlighting fails whenever I extend a function. The added code is formatted as a comment. It is formatted normally after the code runs for awhile.

My best guess is that this might be a matter of two different parsers disagreeing on what constitutes valid code: Skulpt’s, and Anvil’s formatter/syntax-highlighter.

I agree.
… and sometimes it fails when there is a syntax error elsewhere in the app, even if it’s in another file.

But I have just tried, and it seems to be more robust now.
This would have failed a few weeks ago:
image

1 Like

Sorry for the long gap, I got caught up in other issues and only now got time to debug.

The issue seems to be the fact that I’m using the walrus operator. This is despite the fact that my server python environment is python3.10 where that syntax is valid.

So this seems to be a bug.

See this app where the server env is python3.10 and a walrus operator breaks the autocomplete.

This is something we are aware of and currently a limitation of Anvil’s autocompletion (which doesn’t understand 3.8+ syntax features). I’ve moved to bug reports but this isn’t a quick fix bug, so for now I’d recommend avoiding the walrus operator in your code.

2 Likes

I also just noticed that within a TypedDict definition the autocomplete doesn’t work. But it still works outside the TypedDict class definition

class CurriculumData(TypedDict):
    curriculum_type: DbTables
    curriculums: Union[str, list[str]]