refactor(trading-suite): make Features a StrEnum for ruff 0.16 (unblocks #154) - #155
Merged
Merged
Conversation
Switch Features from (str, Enum) to enum.StrEnum so ruff 0.16 UP042 passes. str() and f-strings now return the value (e.g. "orderbook") instead of "Features.X"; equality, .value, and JSON serialization are unchanged. Unblocks Dependabot #154.
Parenthesize the WMA rolling_map lambda and format Python fences in src/project_x_py/utils/README.md so src/ passes both ruff 0.12.8 and 0.16.9 format --check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unblocks #154 (Dependabot python-patch group), whose lint job fails under ruff 0.16.9:
Approved by the owner on 2026-10-04.
Changes
Featuresintrading_suite.pyis nowenum.StrEnum(wasstr, Enum).str(Features.X)and f-strings /format()now return the value (e.g."orderbook") instead of"Features.ORDERBOOK".isinstance(..., str), equality with plain strings,Features("orderbook"), hashing,.value,json.dumps,repr.tests/trading_suite/test_features.py(11 tests: str/f-string, equality, hashing, JSON serialization, config andTradingSuite.create(features=[...])with strings). Written test-first; the 5 str/format/StrEnum tests failed before the change.src/(the "2 files would be reformatted" issue), accepted by both ruff 0.12.8 and 0.16.9:indicators/overlap.py: WMArolling_maplambda body is now in parentheses (no logic change)utils/README.md: Python code fences reformatted (ruff 0.16 now formats Markdown)[Unreleased]→### Changedentry.I searched src/, tests/, docs/, examples/ and README for code that depends on the old
"Features.X"string output and found none. The code uses membership checks,.value, or repr (the init log formats a list, so it still shows the repr). The docs don't mention the base class or the str() output, so no docs changes were needed.uv.lockandpyproject.tomlare unchanged.Gates
uv run ruff check src//uv run ruff format --check src/(0.12.8): passuvx ruff@0.16.9 check src//uvx ruff@0.16.9 format --check src/: passuv run mypy src/: passuv run pytest tests/trading_suite: 112 passeduv run pytest -m "unit and not slow": 2735 passed, 1 failed. The failure (test_get_bars_since_with_pytz_timezone_object,ZoneInfoNotFoundError: 'US/Eastern', local tzdata) also fails on main../check_quality.sh: the failures also happen on main and are outsidesrc/(76 unformatted files and 39 ruff findings in tests/, examples/, scripts/). This PR doesn't touch those files.