From fffb115c55a9bd23779523bb545966a09488c1e9 Mon Sep 17 00:00:00 2001 From: Mihai Date: Mon, 4 Mar 2024 18:15:57 -0500 Subject: [PATCH] allow compatibility with all sub -versions of 3.11 (#30) --- fixedpointmath/__init__.py | 1 + fixedpointmath/errors.py | 1 + fixedpointmath/fixed_point.py | 1 + fixedpointmath/fixed_point_integer_math.py | 1 + fixedpointmath/fixed_point_math.py | 1 + pyproject.toml | 2 +- tests/test_fp_arithmetic_sugar.py | 6 +++--- tests/test_fp_class.py | 1 + tests/test_fp_integer_math.py | 1 + tests/test_fp_math.py | 1 + tests/test_fp_nonfinite_checks.py | 2 ++ tests/test_fp_relational_sugar.py | 2 ++ 12 files changed, 16 insertions(+), 4 deletions(-) diff --git a/fixedpointmath/__init__.py b/fixedpointmath/__init__.py index f8efd10..4664831 100644 --- a/fixedpointmath/__init__.py +++ b/fixedpointmath/__init__.py @@ -1,4 +1,5 @@ """Utility functions for doing special math""" + # Modules imported here are simply for easier namespace resolution, e.g., # from fixedpointmath import FixedPoint # instead of diff --git a/fixedpointmath/errors.py b/fixedpointmath/errors.py index 74377c2..a2c1bc1 100644 --- a/fixedpointmath/errors.py +++ b/fixedpointmath/errors.py @@ -1,4 +1,5 @@ """Define Python user-defined exceptions""" + from __future__ import annotations diff --git a/fixedpointmath/fixed_point.py b/fixedpointmath/fixed_point.py index 159d7d4..be18f64 100644 --- a/fixedpointmath/fixed_point.py +++ b/fixedpointmath/fixed_point.py @@ -1,4 +1,5 @@ """Fixed point datatype & arithmetic""" + from __future__ import annotations import re diff --git a/fixedpointmath/fixed_point_integer_math.py b/fixedpointmath/fixed_point_integer_math.py index b357416..0f44b73 100644 --- a/fixedpointmath/fixed_point_integer_math.py +++ b/fixedpointmath/fixed_point_integer_math.py @@ -1,4 +1,5 @@ """Fixed Point Integer math library""" + from __future__ import annotations from . import errors diff --git a/fixedpointmath/fixed_point_math.py b/fixedpointmath/fixed_point_math.py index 1b7911e..db208df 100644 --- a/fixedpointmath/fixed_point_math.py +++ b/fixedpointmath/fixed_point_math.py @@ -1,4 +1,5 @@ """Math library wrappers that support FixedPoint number format""" + from __future__ import annotations import math diff --git a/pyproject.toml b/pyproject.toml index dfc3e1e..0945ba9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ authors = [ ] description = "Fixed-point arithmetic and type that mirrors popular Solidity implementations" readme = "README.md" -requires-python = ">=3.8, <=3.11" +requires-python = ">=3.8, <3.12" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", diff --git a/tests/test_fp_arithmetic_sugar.py b/tests/test_fp_arithmetic_sugar.py index b45203e..b40bf0c 100644 --- a/tests/test_fp_arithmetic_sugar.py +++ b/tests/test_fp_arithmetic_sugar.py @@ -1,4 +1,5 @@ """Tests for arethmetic syntax sugar with the FixedPoint class""" + import unittest from fixedpointmath import errors @@ -24,6 +25,7 @@ class TestFixedPoint(unittest.TestCase): Instead, `fp(1) == 1e-18`, while `fp(1.0) == 1e18`. """ + ZERO = FixedPoint("0.0") ONE = FixedPoint("1.0") NEG_ONE = FixedPoint("-1.0") @@ -294,9 +296,7 @@ def test_divide(self): assert float(FixedPoint("6.0") / FixedPoint("100.0")) == 0.06 assert float(FixedPoint("0.006") / FixedPoint("0.001")) == 6 # div rounding - assert FixedPoint(scaled_value=2 * 10**18) / FixedPoint(scaled_value=1 * 10**37) == FixedPoint( - scaled_value=0 - ) + assert FixedPoint(scaled_value=2 * 10**18) / FixedPoint(scaled_value=1 * 10**37) == FixedPoint(scaled_value=0) assert FixedPoint(scaled_value=2 * 10**18).div_up(FixedPoint(scaled_value=1 * 10**37)) == FixedPoint( scaled_value=1 ) diff --git a/tests/test_fp_class.py b/tests/test_fp_class.py index ca079a2..d85a1f6 100644 --- a/tests/test_fp_class.py +++ b/tests/test_fp_class.py @@ -1,4 +1,5 @@ """Tests for the FixedPoint class methods""" + import math import unittest from decimal import Decimal diff --git a/tests/test_fp_integer_math.py b/tests/test_fp_integer_math.py index b7d7e1d..0ef1d61 100644 --- a/tests/test_fp_integer_math.py +++ b/tests/test_fp_integer_math.py @@ -1,4 +1,5 @@ """FixedPoint integer math tests inspired from solidity hyperdrive implementation""" + import math import unittest diff --git a/tests/test_fp_math.py b/tests/test_fp_math.py index 853051f..aba3328 100644 --- a/tests/test_fp_math.py +++ b/tests/test_fp_math.py @@ -1,4 +1,5 @@ """FixedPoint class math tests inspired from solidity hyperdrive implementation""" + import math import unittest diff --git a/tests/test_fp_nonfinite_checks.py b/tests/test_fp_nonfinite_checks.py index a4d5d0a..4c6a17c 100644 --- a/tests/test_fp_nonfinite_checks.py +++ b/tests/test_fp_nonfinite_checks.py @@ -1,4 +1,5 @@ """Tests for non-finite (inf or nan) operations with the FixedPoint datatype""" + import unittest from fixedpointmath import FixedPoint @@ -9,6 +10,7 @@ class TestFixedPointNonFinite(unittest.TestCase): Unlike normal integers, the FixedPoint type """ + ZERO = FixedPoint("0.0") ONE = FixedPoint("1.0") NEG_ONE = FixedPoint("-1.0") diff --git a/tests/test_fp_relational_sugar.py b/tests/test_fp_relational_sugar.py index 795aa02..373e4e9 100644 --- a/tests/test_fp_relational_sugar.py +++ b/tests/test_fp_relational_sugar.py @@ -1,4 +1,5 @@ """Tests for relational (comparison) syntax sugar with the FixedPoint class""" + import unittest from fixedpointmath import FixedPoint @@ -11,6 +12,7 @@ class TestFixedPointNonFinite(unittest.TestCase): Unlike normal integers, the FixedPoint type """ + ONE = FixedPoint("1.0") NEG_ONE = FixedPoint("-1.0") ODD_FINITE = FixedPoint("9.0")