Using your comment to bring some nuance to the Gandhi is a dick movement that keeps cropping up everywhere (not saying you hold that view)
For people that are unfamiliar with Gandhi’s racist views towards black people in South Africa here are the most well known quotes of his. But like everything in life, things are more nuanced, I’ll elaborate after the said quotes.
Writing on the subject of immigration in 1903, Gandhi commented: "We believe as much in the purity of race as we think they do... We believe also that the white race in South Africa should be the predominating race."
7 March 1908, Gandhi wrote in the Indian Opinion of his time in a South African prison: "Kaffirs are as a rule uncivilised—the convicts even more so. They are troublesome, very dirty and live almost like animals." and "Many of the native prisoners are only one degree removed from the animal and often created rows and fought among themselves."
South Africa had a policy of racial segregation The problem is judging people from history by modern standards and ignoring how his views changed over a period of 55 years, the racist quotes are at the beginning of that period. South Africa is where his views start to shape and change.
There isn’t much on his relations with the black community after South Africa except, and this isn’t minor that he frequently advocates ‘onesness of humanity’ and there are volumnious writings on the evils of racial pride, etc.
When he went back to India in 1915 a were he starts the independence movement he had some very dogmatic views on the caste system (every Hindu “must follow the hereditary profession”) in India, keeping a prohibition on intermarriages between social classes and interreligion marriages. He also doesn’t like interdining... This was still the case in 1920. In the 30’s he mellows a lot but still advocates for a toned down version of the caste system (with equal social/economic status…) and by the 40’s his views are almost the opposite, he wants to get rid of the caste/class system, advocates for intermarriages between classes and religions (although not as strongly for religion as the rest).
So was he a racist by the time he died? We don’t know, he certainly preached racial equality, he has met with several prominent African-American figures in 1935/36 from the Civil Right Movement in the US (Howard Thurman (1935), Benjamin Mays Elijah (1936), William Stuart Nelson (1936). His views on many inequality subjects which he supported changed drastically. Remember he was also quite pro or at least not against the British Empire when he arrived in SA. He was a human like the rest of us and his views on many subjects changed drastically, and considering the time period (Victorian era - WWII) that are some drastic changes. There is a lot of weird things about him and he wasn’t right on many things but be careful with judging his actions through the cultural standards of today it is not the same era nor the same culture and most people were openly racist back then and he openly supported equality towards the end.
TL;DR: Don't judge figures from the past by standards of the present. He certainly wasn't perfect, but between those racist statements and his death (55 year period) he went from supporting class system, prohibiting intermarriage between classes and religions, moving from pro (or not against) British Imperialism to against and openly preached for racial equality.