Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for levels property #44

Merged
merged 4 commits into from
Nov 26, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}

steps:
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Unreleased (Nov 2023)
# Unreleased

## Additions

- Add `at_random` method to `BaseEnum` for picking an enum value at random.
- Add `at_random` method to `BaseEnum` for generating an enum variant at random.
- Add `levels` property to `CompetitionParticipationDetail`.

## Changes

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
8 changes: 6 additions & 2 deletions wom/models/competitions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ class CompetitionParticipation(BaseModel):
"""

player: Player
"""The [`Player`][wom.Player] that participated in this competition.
"""
"""The [`Player`][wom.Player] that participated in this competition."""


@attrs.define(init=False)
Expand Down Expand Up @@ -187,6 +186,11 @@ class CompetitionParticipationDetail(BaseModel):
made.
"""

levels: t.Optional[CompetitionProgress]
"""The optional [`CompetitionProgress`][wom.CompetitionProgress] as it
relates the number of overall levels gained. Can be `None` if this is not a
skilling competition, or the player is unranked in the skill."""


@attrs.define(init=False)
class CompetitionDetail(BaseModel):
Expand Down
14 changes: 10 additions & 4 deletions wom/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,10 +946,16 @@ def deserialize_competition_participation_detail(
Returns:
The requested model.
"""
participation_details = models.CompetitionParticipationDetail()
participation_details.participation = self.deserialize_competition_participation(data)
participation_details.progress = self.deserialize_competition_progress(data["progress"])
return participation_details
details = models.CompetitionParticipationDetail()
details.participation = self.deserialize_competition_participation(data)
details.progress = self.deserialize_competition_progress(data["progress"])

if levels := data.get("levels", None):
details.levels = self.deserialize_competition_progress(levels)
else:
details.levels = levels

return details

@serializer_guard
def deserialize_competition_history_data_point(
Expand Down