A magic school setting may be a more traditional setting for a fantasy novel, but there are some select anime that take place in schools of the magical and alchemical arts. Some magic school anime incorporate elements of the magical girl subgenre, and others commentate on classic stories like the Harry Potter series.
Source:https://www.cbr.com/best-magical-school-anime-ranked/