Remove "returns" dependency
This commit is contained in:
parent
c8b6563d17
commit
68b3749ff3
3 changed files with 6 additions and 10 deletions
|
@ -3,8 +3,6 @@ import enum
|
|||
import fractions
|
||||
import typing
|
||||
|
||||
from returns.maybe import Maybe, Some, Nothing
|
||||
|
||||
from elite_engineering import trade
|
||||
|
||||
|
||||
|
@ -157,9 +155,9 @@ class Material:
|
|||
|
||||
MAX_CAPACITY: int = 300
|
||||
|
||||
def trade_ratio(self, other: "Material") -> Maybe[fractions.Fraction]:
|
||||
def trade_ratio(self, other: "Material") -> typing.Optional[fractions.Fraction]:
|
||||
if self.type_ != other.type_:
|
||||
return Nothing
|
||||
return None
|
||||
return trade.ratio(self.grade, other.grade, self.category != other.category)
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import fractions
|
||||
|
||||
from returns.maybe import Maybe, Nothing, Some
|
||||
import typing
|
||||
|
||||
MAX_CAPACITY: int = 300
|
||||
|
||||
|
||||
def ratio(
|
||||
grade_in: int, grade_out: int, across_categories: bool
|
||||
) -> Maybe[fractions.Fraction]:
|
||||
) -> typing.Optional[fractions.Fraction]:
|
||||
trading_up = grade_out > grade_in
|
||||
grade_base = 6 if trading_up else 3
|
||||
grade_ratio = fractions.Fraction(grade_base ** grade_out, grade_base ** grade_in)
|
||||
|
@ -16,6 +15,6 @@ def ratio(
|
|||
)
|
||||
result = grade_ratio * category_ratio
|
||||
if max(result.numerator, result.denominator) > MAX_CAPACITY:
|
||||
return Nothing
|
||||
return None
|
||||
else:
|
||||
return Some(result)
|
||||
return result
|
||||
|
|
|
@ -7,7 +7,6 @@ license = "MIT"
|
|||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.9"
|
||||
returns = "^0.18.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
black = "^21.12b0"
|
||||
|
|
Loading…
Reference in a new issue