Be careful with that. In our area, homeowners can pull permits and do work themselves without using licensed subs. But in most cities, that’s only for properties you occupy. If its a flip or a rental, you must have a licensed GC pull the permits and certain trades (mechanical, plumbing electric) must be licensed.
In the situation Don mentioned I later found out the city inspectors look for for-sale signs and look at the property. If it appears to be rehabbed, they check for permits. If there are no permits, then they demand inspections.