Skip to content

Commit

Permalink
Remove dependency on toml and types-toml (#72)
Browse files Browse the repository at this point in the history
Refactor field renaming for group statistics
  • Loading branch information
Jonxslays authored Mar 25, 2024
1 parent 53c14e1 commit 414dd07
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
11 changes: 7 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@
from pathlib import Path

import nox
import toml
import msgspec

SessionT = Callable[[nox.Session], None]
InjectorT = Callable[[SessionT], SessionT]


def parse_dependencies() -> t.Dict[str, str]:
data = toml.load("pyproject.toml")["tool"]["poetry"]
with open("pyproject.toml", "rb") as f:
data = msgspec.toml.decode(f.read())

poetry = data["tool"]["poetry"]
deps: t.Dict[str, t.Union[str, t.Dict[str, str]]] = {
**data["dependencies"],
**data["group"]["dev"]["dependencies"],
**poetry["dependencies"],
**poetry["group"]["dev"]["dependencies"],
}

for k, v in deps.items():
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ pyright = "==1.1.344"
pytest = "==7.4.4"
pytest-asyncio = "==0.23.3"
pytest-testdox = "==3.1.0"
types-toml = "==0.10.8.7"
toml = "==0.10.2"

[tool.black]
line-length = 99
Expand Down
15 changes: 4 additions & 11 deletions wom/models/groups/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import typing as t
from datetime import datetime

import msgspec

from wom import enums

from ..base import BaseModel
Expand Down Expand Up @@ -318,16 +320,7 @@ class MetricLeaders(BaseModel):
"""


class GroupStatistics(
BaseModel,
rename={
"maxed_combat_count": "maxedCombatCount",
"maxed_total_count": "maxedTotalCount",
"maxed_200ms_count": "maxed200msCount",
"average_stats": "averageStats",
"metric_leaders": "metricLeaders",
},
):
class GroupStatistics(BaseModel):
"""Represents accumulated group statistics."""

maxed_combat_count: int
Expand All @@ -336,7 +329,7 @@ class GroupStatistics(
maxed_total_count: int
"""The number of maxed total level players in the group."""

maxed_200ms_count: int
maxed_200ms_count: int = msgspec.field(name="maxed200msCount")
"""The number of maxed 200M xp players in the group."""

average_stats: Snapshot
Expand Down

0 comments on commit 414dd07

Please sign in to comment.