Welcome to BP.net!
I think the question of when to upgrade your tank size depends a bit on the snake itself. You've had it for awhile now, so you know it's personality. If it eats readily and handles easily, it may not mind a bigger home at all. If it seems perpetually shy and insecure...it may not adjust to a new home very easily.
My suggestion: Set up the 40gal just as if you had the snake in it...make sure you can get it to run reliably holding proper temps and humidity. Maybe cover three sides of the glass with paper or something to help it feel less open. (Pet stores have very pretty decorative "wall paper" you can use) Put in several hides for it to choose from.
Once you get it all set up and running properly...put the snake in and give it a few weeks to see if it adjusts well. It may skip a meal or two during this adjustment period. If the snake won't start eating again or seems otherwise stressed out and not acting normally....move it back into the 10gal and wait awhile longer before upgrading size.