"gnat type"...you mean tiny flying bugs? (mites do not fly)
If gnats, mostly an annoyance: I've heard of some people 'baking' substrate (in low temp. oven) to kill any such bugs, but that's not too practical if you use a lot
of substrate for a larger cage or multiple cages. If you happen to live where it's really hot & dry (desert?) you can put the sun to work: put substrate in clean metal
trash can out in the sun (with lid on) & let it bake a while...gnats won't live thru that.
Obviously, you don't want to use any sort of pesticide to kill them as it would kill or make your snake sick too.