Python Generator

111 views
Skip to first unread message

Stuart Barclay

unread,
Jul 17, 2024, 1:10:54 PM7/17/24
to Blockly
I am writing a python workspace where with blockly in typescript. The workspace has several custom blocks and requires imports (either of other custom blocks or external python libraries), however I am getting a type warning when using `pythonGenerator.definitions_` as defintions_ is protected.

Is there a way to add to the definitions_ without getting this warning?

Beka Westberg

unread,
Jul 18, 2024, 12:52:12 PM7/18/24
to Blockly
Currently not :/ We have issue 7600 and issue 7326 tracking fixing this, but for now we just cast to `any` in core. I've put 7326 back into the triage queue since you're running into it =)

Sorry I don't have a better answer for you at the moment! Best of luck with your project,
--Beka

Christopher Allen

unread,
Jul 22, 2024, 7:45:10 AM7/22/24
to blo...@googlegroups.com
Hi Stuart,

Is there a way to add to the definitions_ without getting this warning?

As Beka noted, we don't really have a good solution to this at the moment, and even the Python generator functions for the library blocks have to work around this problem—but that same workaround should work for you too for the time being—just beware that it might stop working at some point in the future (by which time, hopefully, we will have a better solution).

Sorry about that.


Christopher

Stuart Barclay

unread,
Jul 24, 2024, 8:30:10 AM7/24/24
to Blockly

Thank you so much Beka @ Christopher!

Stuart Barclay

unread,
Mar 3, 2026, 7:07:38 AM (2 days ago) Mar 3
to Blockly
Hello all!

I am following up to see if there is a better workaround now in version 12?

Kind regards 
Stuart
Reply all
Reply to author
Forward
0 new messages