tybug / ossapi

The definitive python wrapper for the osu! api.
https://tybug.github.io/ossapi/
GNU Affero General Public License v3.0
80 stars 17 forks source link

Clean & Pythonic Code #59

Closed suffixing closed 1 year ago

suffixing commented 1 year ago
if isinstance(value, list):
    return cls(*[getattr(cls, val.upper()) for val in value])

return getattr(cls, value.upper(), super()._missing_(value))

replaced if statements with a getattr() call, converts the input to uppercase, and used a list comprehension

return getattr(cls, value.upper(), super()._missing_(value))

return the attribute with given value using getattr(). If the attribute is not found, it falls back to the default _missing_ implementation.