From f1164819fe3f7697f78c17f0ac92488fe1262f85 Mon Sep 17 00:00:00 2001 From: Xuan Ronaldo Date: Wed, 11 Dec 2024 19:28:34 +0800 Subject: [PATCH] fix: correct type comparison in IndicatorRegistry.available_indicators Fix type comparison issue in the available_indicators property of IndicatorRegistry class. Ensure all keys are converted to strings before sorting to avoid TypeError when comparing method and str types. - Add explicit string conversion in available_indicators property - Fix type error in unit tests --- .github/workflows/python-publish.yml | 2 +- setup.py | 2 +- src/positionbt/indicators/registry.py | 2 +- .../intergration/{test_backtester.py => test_backtester_it.py} | 0 tests/unit/{test_backtester.py => test_backtester_ut.py} | 0 5 files changed, 3 insertions(+), 3 deletions(-) rename tests/intergration/{test_backtester.py => test_backtester_it.py} (100%) rename tests/unit/{test_backtester.py => test_backtester_ut.py} (100%) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index f76a662..ec59a5e 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v3 diff --git a/setup.py b/setup.py index aac21a4..67ab5f5 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], - python_requires=">=3.7", + python_requires=">=3.10", install_requires=[ "polars>=0.20.0", "pandas>=2.0.0", diff --git a/src/positionbt/indicators/registry.py b/src/positionbt/indicators/registry.py index 8ff60e2..d58544f 100644 --- a/src/positionbt/indicators/registry.py +++ b/src/positionbt/indicators/registry.py @@ -90,7 +90,7 @@ def available_indicators(self) -> list[str]: Sorted list of registered indicator names """ - return sorted(self._indicators.keys()) + return sorted(str(key) for key in self._indicators.keys()) @property def sorted_indicators(self) -> dict[str, type[BaseIndicator]]: diff --git a/tests/intergration/test_backtester.py b/tests/intergration/test_backtester_it.py similarity index 100% rename from tests/intergration/test_backtester.py rename to tests/intergration/test_backtester_it.py diff --git a/tests/unit/test_backtester.py b/tests/unit/test_backtester_ut.py similarity index 100% rename from tests/unit/test_backtester.py rename to tests/unit/test_backtester_ut.py