Parity anomaly with impurities and the Pauli--Villars subtraction