"The developer who worked at Microsoft to make iron python" - Jim Hugunin [1] (say his name!) to whom much is owed by the python community and humanity, generally.
I would refine this advice to "sarcasm is never appropriate in an uneven power dynamic." Whether it's in the context of parenting, teaching or managing people. As a go-to form of humor, I've learned this the hard way. It's not actually helpful for folks to hear the hilarious monologue going on in my head when I'm feeling salty. There _are_ legitimately relationship-building funny things to say, but they're usually self-effacing and, at best, complementary to others.
[1] https://en.wikipedia.org/wiki/Jim_Hugunin