As I mentioned it in this blog post, the new version of Python (3.7.3) that Fusion 360 migrated to seems more strict, and is causing some add-ins to fail.
Here are the main issues I've seen pop up:
1) Having an empty code block: if/else, try/except, etc
Code:
try: except:
Error:
Sorry: IndentationError: expected an indented block (PythonTest.py, line 25)
Solution: remove the whole block or just put a "pass" inside it:
try: pass except: pass
2) Referencing a global variable multiple times in the same function using the "global" keyword - even if from different execution paths
Code:
my_global_variable = "" def run(context): if ui: global my_global_variable my_global_variable = "True" else: global my_global_variable my_global_variable = "False"
Error:
SyntaxError: name 'my_global_variable' is assigned to before global declaration
Solution: use the "global" references at the beginning of the function
my_global_variable = "" def run(context): global my_global_variable if ui: my_global_variable = "True" else: my_global_variable = "False"
3) One other issue, which is not necessarily a result of the compiler's strictness, is that you may be relying on packages that are based on an earlier version of Python. If loading those modules is causing errors then you might have to upgrade those packages. It might be done in different ways depending on where you got those packages from.