Skip to content

Commit 4b28530

Browse files
committed
fix: properly initialize _single_context to resolve IDE warnings
- Changed _single_context declaration to proper initialization with conditional expression - Eliminates 'unknown variable' warnings in IDEs - Maintains same functionality with cleaner, more explicit initialization - Improves code readability and type checker satisfaction
1 parent ba7b5ad commit 4b28530

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/project_x_py/trading_suite.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,13 @@ def __init__(
282282
# Multi-instrument support
283283
self._instruments: dict[str, InstrumentContext] = instrument_contexts or {}
284284
self._is_single_instrument = len(self._instruments) == 1
285-
self._single_context: InstrumentContext | None # For backward compatibility
286-
if self._is_single_instrument and self._instruments:
287-
self._single_context = next(iter(self._instruments.values()))
288-
else:
289-
self._single_context = None
285+
286+
# For backward compatibility - store single context if available
287+
self._single_context: InstrumentContext | None = (
288+
next(iter(self._instruments.values()))
289+
if self._is_single_instrument and self._instruments
290+
else None
291+
)
290292

291293
# Legacy single-instrument properties (for backward compatibility)
292294
self._symbol = config.instrument # Store original symbol

0 commit comments

Comments
 (0)