It's far more racist to say that roles should be cast around making sure no actor even remotely coincides with any stereotype than it is to cast a role in a way that's similar to a stereotype.
Believe it or not there were tribes with gender attitudes similar to that of all variety of races in Earth history.
Did Code Of Honor actually leave you with the impression that all black people were savages who kidnapped white women? If it did leave you with that impression it says more about you than the episode. The episode was about a group of aliens with gender cultures similar to thousands of years old gender cultures from all parts of Earth, the fact that they had high melanin content in their skin was incidental.
I suppose Stargate is racist for portraying Egyptians as worshipping alien parasites.