Political affiliation is not a protected class at the federal level. If a city has an ordinance against it, that is specific to that city, but in the city where I live, it is not illegal. In fact it is quite common for Assistant DA’s and Sheriff’s Deputies to be replaced based on political affiliation when a new DA or Sheriff comes into office where I live. I live in a major metro area in the south.
It’s not considered wrongful where I live (major metro area in the south). It is standard practice. Prosecutors and deputies are regularly let go in large numbers based on political affiliation when a new DA or Sheriff takes office. It’s just considered part of the job around here.