diff --git a/docs/changelog.rst b/docs/changelog.rst index 92937c9c..e1cc6fa0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,16 @@ Changelog ========= +.. _vp4p0p0: + +v4.0.0 +------- + +Breaking Changes +~~~~~~~~~~~~~~~~ +- If :attr:`fortnite_api.VariantBean.gender` isn't present, it's now ``None``, instead of ``CustomGender.UNKNOWN``. +- ``CustomGender.UNKNOWN`` has been removed, hence it's not used anymore. + .. _vp3p4p0: v3.4.0 @@ -44,7 +54,7 @@ v3.2.1 Bug Fixes ~~~~~~~~~ -- Fixed an issue due a change from Epic that causes :class:`fortnite_api.VariantBean` to not have a :class:`fortnite_api.CustomGender`. It now uses :attr:`fortnite_api.CustomGender.UNKNOWN` in such case instead of raising an exception. +- Fixed an issue due a change from Epic that causes :class:`fortnite_api.VariantBean` to not have a :class:`fortnite_api.CustomGender`. It now uses ``CustomGender.UNKNOWN`` in such case instead of raising an exception. - Fixed typo within fallback system for :class:`fortnite_api.TileSize` as ``raise`` keyword was used instead of ``return``. - Fixed an issue that caused a :class:`KeyError` to be raised when using :meth:`fortnite_api.Client.search_br_cosmetics` or :meth:`fortnite_api.SyncClient.search_br_cosmetics` without ``multiple`` parameter. diff --git a/fortnite_api/cosmetics/variants/bean.py b/fortnite_api/cosmetics/variants/bean.py index 8fe6ab16..bb6ee4bb 100644 --- a/fortnite_api/cosmetics/variants/bean.py +++ b/fortnite_api/cosmetics/variants/bean.py @@ -55,8 +55,8 @@ class VariantBean(Cosmetic[dict[str, Any], HTTPClientT]): The ID of the cosmetic that this bean represents, if any. name: :class:`str` The name of this bean. - gender: :class:`fortnite_api.CustomGender` - Denotes the gender of this bean. + gender: Optional[:class:`fortnite_api.CustomGender`] + Denotes the gender of this bean. Can be ``None`` if no gender is assigned. gameplay_tags: List[:class:`str`] The gameplay tags associated with this bean. @@ -76,7 +76,9 @@ def __init__(self, *, data: dict[str, Any], http: HTTPClientT) -> None: self.cosmetic_id: str | None = data.get('cosmetic_id') self.name: str = data['name'] - self.gender: CustomGender = try_enum(CustomGender, data['gender'] if 'gender' in data else 'Unknown') + + _gender = data.get("gender") + self.gender: CustomGender | None = _gender and try_enum(CustomGender, _gender) self.gameplay_tags: list[str] = get_with_fallback(data, 'gameplay_tags', list) _images = data.get('images') diff --git a/fortnite_api/enums.py b/fortnite_api/enums.py index b065232a..921f0202 100644 --- a/fortnite_api/enums.py +++ b/fortnite_api/enums.py @@ -557,13 +557,10 @@ class CustomGender(Enum): A female character. MALE A male character. - UNKNOWN - The character's gender is unknown. """ FEMALE = 'EFortCustomGender::Female' MALE = 'EFortCustomGender::Male' - UNKNOWN = 'Unknown' class ProductTag(Enum): diff --git a/tests/cosmetics/cosmetic_utils.py b/tests/cosmetics/cosmetic_utils.py index f100e8e5..5f926762 100644 --- a/tests/cosmetics/cosmetic_utils.py +++ b/tests/cosmetics/cosmetic_utils.py @@ -177,7 +177,10 @@ def validate_variant_lego(variant: fortnite_api.VariantLego[Any]): def validate_variant_bean(variant: fortnite_api.VariantBean[Any]): assert isinstance(variant, fortnite_api.VariantBean) assert variant.name - assert isinstance(variant.gender, fortnite_api.CustomGender) + + gender = variant.gender + if gender: + assert isinstance(gender, fortnite_api.CustomGender) images = variant.images if images: