From db2db672a25f0ab9c3abb65293644719da207e96 Mon Sep 17 00:00:00 2001 From: Conor Heine <1045603+cahna@users.noreply.github.com> Date: Tue, 31 Jan 2023 12:09:56 -0800 Subject: [PATCH] v0.1.1: bugfix for pydantic model root validator (#7) --- hitfactorpy/pydantic_/models.py | 9 ++++----- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hitfactorpy/pydantic_/models.py b/hitfactorpy/pydantic_/models.py index ab703bc..769b7d7 100644 --- a/hitfactorpy/pydantic_/models.py +++ b/hitfactorpy/pydantic_/models.py @@ -40,11 +40,10 @@ def _coerce_time_into_decimal(cls, v): @root_validator(pre=True) def _coerce_hit_factor_to_decimal_or_calculate_if_unset(cls, values): hit_factor = values.get("hit_factor") - if hit_factor is None: - values["hit_factor"] = calculate_hit_factor(**values) - else: - values["hit_factor"] = D4(hit_factor) - return values + return { + **values, + "hit_factor": calculate_hit_factor(**values) if hit_factor is None else D4(hit_factor), + } @root_validator def _check_hit_factor_matches_calculated_hit_factor(cls, values): diff --git a/pyproject.toml b/pyproject.toml index 7fdce83..96f4f6e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "hitfactorpy" -version = "0.1.0" +version = "0.1.1" description = "Python tools for parsing and analyzing practical match reports" authors = ["Conor Heine "] readme = "README.md"