The appeal to purity fallacy and the no true Scotsman fallacy are closely related, but the appeal to purity fallacy is broader:
Appeal to purity fallacies dismiss deviations from an idealized form, rejecting any variation or nuance within a belief system or identity.
No true Scotsman fallacies are a type of appeal to purity that involves dismissing counterexamples to defend a specific claim.