Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Changelog
v3.3.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.

Bug Fixes
~~~~~~~~~
- Fixed an issue that caused :class:`fortnite_api.Asset.resize` to raise :class:`TypeError` instead of :class:`ValueError` when the given size isn't a power of 2.
Expand All @@ -23,7 +28,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.

Expand Down
8 changes: 5 additions & 3 deletions fortnite_api/cosmetics/variants/bean.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -76,7 +76,9 @@ def __init__(self, *, data: dict[str, Any], http: HTTPClientT) -> None:

self.cosmetic_id: Optional[str] = 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: Optional[CustomGender] = _gender and try_enum(CustomGender, _gender)
self.gameplay_tags: list[str] = get_with_fallback(data, 'gameplay_tags', list)

_images = data.get('images')
Expand Down
3 changes: 0 additions & 3 deletions fortnite_api/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,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):
Expand Down
5 changes: 4 additions & 1 deletion tests/test_async_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ async def test_async_fetch_variants_beans(api_key: str, response_flags: fn_api.R
def _test_variant_bean(variant: fn_api.VariantBean[Any]):
assert isinstance(variant, fn_api.VariantBean)
assert variant.name
assert isinstance(variant.gender, fn_api.CustomGender)

gender = variant.gender
if gender:
assert isinstance(gender, fn_api.CustomGender)

images = variant.images
if images:
Expand Down