Skip to content

Commit

Permalink
feat(EmissionFactor): fix returned error type
Browse files Browse the repository at this point in the history
  • Loading branch information
redfrexx committed Nov 12, 2024
1 parent 82ccde2 commit 6f4b507
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions co2calculator/api/emission_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ class EmissionFactor:
"""Stores information on emission factors"""

factor: float
source: str
source: str = None

def __post_init__(self):
"""Validate the attribute values"""
if isinstance(self.factor, (int, float)):
assert self.factor >= 0, "Emission factor must be positive"
if not isinstance(self.factor, (int, float)):
raise TypeError("Emission factor must be a number")
elif self.factor < 0:
raise ValueError("Emission factor must be positive")
pass

0 comments on commit 6f4b507

Please sign in to comment.