Have you tried ignoring it?
This is probably one of those attention getting behaviors. With puppies, anything can be perceived as a reward, even looking at them can be a reward. That means that whatever you have been trying to do to get him to stop, yelling no, flipping him, grabbing his muzzle, pushing him off, grabbing him by the scruff, saying stop, stop walking it etc was only awknowledging the behavior and reinforcing it.
To stop it, you must ignore it completely and teach him another, polite way to get attention. If he does it while you are walking, just keep walking and doing whatever you are doing. Don't awknowledge it in the slightest, don't even look at him. Pretend like it's not even happening. If he gets your leg, try your best to refrain from reacting.
Now if he's doing it and your not giving him attention for it, he is likely to sit down somewhat confused. If he sits down, awknowledge it! He is performing a good behavior. He will soon learn that sitting down and looking at you gets him attention and biting your clothing doesn't.
Another thing you might want to try if he knows a simple command like sit. If you see him coming towards you and you know he's about ready to grab your pant leg, then catch him before he gets to you and tell him to sit. Then reward him for sitting. He should start coming to you and sitting.