44 phrases = [phrase.strip() for phrase in phrases if phrase.strip()]
45
46 phrases_contenders = set(phrases)
47 phrases_already_in_db = set([phrase.word for phrase in guild_service.get_guild().raid_phrases]) 48
49 duplicate_count = len(phrases_already_in_db & phrases_contenders) # count how many duplicates we have
50 new_phrases = list(phrases_contenders - phrases_already_in_db)
Although there is nothing syntactically wrong with this code, it is hard to read and can be simplified to a set comprehension. Using set comprehension is more performant since there is no need to create a transient list.
mapping = set([num for num in my_magic_nums])
mapping = {num for num in my_magic_nums}