Skip to content

Commit

Permalink
Remove weakref slots from models (#52)
Browse files Browse the repository at this point in the history
* Remove weakref slots

* Update changelog

* Bump project version
  • Loading branch information
Jonxslays committed Nov 28, 2023
1 parent 4aa05ca commit 8cff1ec
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 66 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Unreleased
# v0.9.0 (Nov 2023)

## Additions

Expand All @@ -12,6 +12,7 @@

- Methods that previously accepted only `GroupMemberFragment` now accept strings as well.
- Update examples in `GroupService` that work with `GroupMemberFragment`.
- Remove usage of weakref slots throughout the project, improving memory footprint.

---

Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "wom.py"
version = "0.8.1"
version = "0.9.0"
description = "An asynchronous wrapper for the Wise Old Man API."
authors = ["Jonxslays"]
license = "MIT"
Expand Down Expand Up @@ -79,6 +79,9 @@ reportImportCycles = false
[tool.pytest.ini_options]
asyncio_mode = "auto"

[tool.ruff]
ignore = ["F405", "F403"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion wom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from typing import Final

__packagename__: Final[str] = "wom.py"
__version__: Final[str] = "0.8.1"
__version__: Final[str] = "0.9.0"
__author__: Final[str] = "Jonxslays"
__copyright__: Final[str] = "2023-present Jonxslays"
__description__: Final[str] = "An asynchronous wrapper for the Wise Old Man API."
Expand Down
2 changes: 1 addition & 1 deletion wom/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import attrs


@attrs.define
@attrs.define(weakref_slot=False)
class BaseModel:
"""The base model all library models inherit from."""

Expand Down
24 changes: 12 additions & 12 deletions wom/models/competitions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class CompetitionProgress(BaseModel):
"""Represents progress in a competition."""

Expand All @@ -65,7 +65,7 @@ class CompetitionProgress(BaseModel):
"""The amount of progress gained in the metric."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class Competition(BaseModel):
"""Represents a competition."""

Expand Down Expand Up @@ -108,7 +108,7 @@ class Competition(BaseModel):
"""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class Participation(BaseModel):
"""Represents participation in a competition."""

Expand All @@ -128,7 +128,7 @@ class Participation(BaseModel):
"""The date this participation was updated."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class CompetitionParticipation(BaseModel):
"""Represents a competition participation."""

Expand All @@ -141,7 +141,7 @@ class CompetitionParticipation(BaseModel):
"""The [`Player`][wom.Player] that participated in this competition."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class PlayerParticipation(BaseModel):
"""Represents a players participation in a competition."""

Expand All @@ -154,7 +154,7 @@ class PlayerParticipation(BaseModel):
"""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class PlayerCompetitionStanding(BaseModel):
"""Represents a players standing in a competition."""

Expand All @@ -172,7 +172,7 @@ class PlayerCompetitionStanding(BaseModel):
"""The rank in the competition standings."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class CompetitionParticipationDetail(BaseModel):
"""Represents competition participation details."""

Expand All @@ -192,7 +192,7 @@ class CompetitionParticipationDetail(BaseModel):
competitions."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class CompetitionDetail(BaseModel):
"""Represents competition details."""

Expand All @@ -206,7 +206,7 @@ class CompetitionDetail(BaseModel):
"""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class CompetitionHistoryDataPoint(BaseModel):
"""A competition history data point."""

Expand All @@ -217,7 +217,7 @@ class CompetitionHistoryDataPoint(BaseModel):
"""The value of the data point."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class Top5ProgressResult(BaseModel):
"""A top 5 progress result for a competition."""

Expand All @@ -231,7 +231,7 @@ class Top5ProgressResult(BaseModel):
"""


@attrs.define
@attrs.define(weakref_slot=False)
class Team(BaseModel):
"""Represents a competition team.
Expand All @@ -258,7 +258,7 @@ def __init__(self, name: str, participants: t.List[str]) -> None:
"""A list of participant usernames on the team."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class CompetitionWithParticipations(BaseModel):
"""Represents a competition with participations."""

Expand Down
2 changes: 1 addition & 1 deletion wom/models/deltas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
__all__ = ("DeltaLeaderboardEntry",)


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class DeltaLeaderboardEntry(BaseModel):
"""Represents a leaderboard entry over the given delta."""

Expand Down
40 changes: 20 additions & 20 deletions wom/models/groups/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
)


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class Group(BaseModel):
"""Represents a group of players on WOM."""

Expand Down Expand Up @@ -103,7 +103,7 @@ class Group(BaseModel):
"""The number of members in the group."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupDetail(BaseModel):
"""Represents details about a group."""

Expand All @@ -125,7 +125,7 @@ class GroupDetail(BaseModel):
"""


@attrs.define
@attrs.define(weakref_slot=False)
class SocialLinks(BaseModel):
"""A groups social links."""

Expand Down Expand Up @@ -159,7 +159,7 @@ def __init__(
"""The groups twitch url."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class Membership(BaseModel):
"""Represents a membership in a group."""

Expand All @@ -179,7 +179,7 @@ class Membership(BaseModel):
"""The date this membership was updated."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupMembership(BaseModel):
"""Represents a group membership."""

Expand All @@ -190,7 +190,7 @@ class GroupMembership(BaseModel):
"""The [`Membership`][wom.Membership] itself."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class PlayerMembership(BaseModel):
"""Represents a player membership."""

Expand All @@ -201,7 +201,7 @@ class PlayerMembership(BaseModel):
"""The [`Membership`][wom.Membership] itself."""


@attrs.define
@attrs.define(weakref_slot=False)
class GroupMemberFragment(BaseModel):
"""Represents a condensed group member.
Expand Down Expand Up @@ -229,7 +229,7 @@ def __init__(self, username: str, role: t.Optional[GroupRole] = None) -> None:
"""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupHiscoresEntry(BaseModel):
"""Represents a group hiscores entry."""

Expand All @@ -245,7 +245,7 @@ class GroupHiscoresEntry(BaseModel):
"""The data for this hiscores entry."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupHiscoresSkillItem(BaseModel):
"""Represents a group hiscores item for skills."""

Expand All @@ -259,7 +259,7 @@ class GroupHiscoresSkillItem(BaseModel):
"""The experience in the skill."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupHiscoresBossItem(BaseModel):
"""Represents a group hiscores item for bosses."""

Expand All @@ -270,7 +270,7 @@ class GroupHiscoresBossItem(BaseModel):
"""The number of boss kills."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupHiscoresActivityItem(BaseModel):
"""Represents a group hiscores item for activities."""

Expand All @@ -281,7 +281,7 @@ class GroupHiscoresActivityItem(BaseModel):
"""The activity score."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupHiscoresComputedMetricItem(BaseModel):
"""Represents a group hiscores item for computed metrics."""

Expand All @@ -292,7 +292,7 @@ class GroupHiscoresComputedMetricItem(BaseModel):
"""The value of the computed metric."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class SkillLeader(BaseModel):
"""Represents a leader in a particular skill."""

Expand All @@ -312,7 +312,7 @@ class SkillLeader(BaseModel):
"""The player leading in this metric, or `None` if none do."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class BossLeader(BaseModel):
"""Represents a leader in a particular boss."""

Expand All @@ -329,7 +329,7 @@ class BossLeader(BaseModel):
"""The player leading in this metric, or `None` if none do."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class ActivityLeader(BaseModel):
"""Represents a leader in a particular activity."""

Expand All @@ -346,7 +346,7 @@ class ActivityLeader(BaseModel):
"""The player leading in this metric, or `None` if none do."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class ComputedMetricLeader(BaseModel):
"""Represents a leader in a particular computed metric."""

Expand All @@ -365,7 +365,7 @@ class ComputedMetricLeader(BaseModel):
"""The player leading in this metric, or `None` if none do."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class MetricLeaders(BaseModel):
"""The leaders for each metric in a group."""

Expand All @@ -390,7 +390,7 @@ class MetricLeaders(BaseModel):
"""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupStatistics(BaseModel):
"""Represents accumulated group statistics."""

Expand All @@ -412,7 +412,7 @@ class GroupStatistics(BaseModel):
"""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupMemberGains(BaseModel):
"""Represents a leaderboard entry over the given delta."""

Expand All @@ -429,7 +429,7 @@ class GroupMemberGains(BaseModel):
"""The [`Gains`][wom.Gains] for this group member."""


@attrs.define(init=False)
@attrs.define(init=False, weakref_slot=False)
class GroupActivity(BaseModel):
"""An activity that occurred in a group."""

Expand Down
4 changes: 2 additions & 2 deletions wom/models/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
__all__ = ("HttpErrorResponse", "HttpSuccessResponse")


@attrs.define
@attrs.define(weakref_slot=False)
class HttpErrorResponse(BaseModel):
"""Indicates something went wrong during the request."""

Expand All @@ -41,7 +41,7 @@ class HttpErrorResponse(BaseModel):
"""The error message."""


@attrs.define
@attrs.define(weakref_slot=False)
class HttpSuccessResponse(BaseModel):
"""Indicates a successful HTTP response."""

Expand Down
Loading

0 comments on commit 8cff1ec

Please sign in to comment.