Should I be using "assert" in my code?

I started out writing a load of typechecks for my functions and such.
But I only recently learned about the assert statement.
If I read correctly, assert checks can be omitted in production code.
But pyrevit raises assertion errors anyway, so I suspect there’s no such thing as “dev” and “production” code in pyrevit. Right?

I was wondering if I should write assert statements regardless and just “go with it” with hopes of being able to disable them for users eventually?

Or perhaps remove assertions from my code (or replace them with typechecks) when I’m finished with a script?

Or should I not use assert at all?

Curious on your opinions.

To remove the asserts in regular python, you should use the -O option or PYTHONOPTIMIZE env var.

I don’t know if pyRevit’s python engine handles environment variables, but you can do a quick test setting it.

As per the other questions: the common paradigm with python is Better Ask for Forgiveness than Permission, so I usually use try/except to catch type/attribute errors.
This way you also leverage duck typing: instead of checking if a parameter of your function is a Duck, you just try to make it .quack(); that way you’re future proofing your function for new, unrelated classes such as QuackingAlarmClock

Did a test, no luck. Oh well, not a big loss.

Thanks for the info, really appreciate it.