Consider merging these comparisons with 'in' by using 'emoji in ('4️⃣', '6️⃣')'. Use a set instead if elements are hashable.
213
214 def get_file_path(self, emoji: str) -> str:
215 code_points = [f'{ord(c):x}' for c in emoji]
216 if emoji == "4️⃣" or emoji == '6️⃣':217 del code_points[1]
218 file_path = f"./resources/emoji/twemoji/assets/72x72/{'-'.join(code_points)}.png"
219 return file_path
Description
To check if a variable is equal to one of many values, combine the values into a tuple and check if the variable is contained in
it instead of checking for equality against each of the values.
This is faster, less verbose, and more readable.
Bad practice
if x == 1 or x == 2 or x == 3:
do_something()
Recommended
if x in (1, 2, 3):
do_something()