Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Internal

- Bump mypy to 2.4.0 and drop now-unused type ignores (supersedes #163).
- Normalize Polars `Series.sum()` aggregates to `float`/`int` before
arithmetic so mypy is clean under polars 1.44 (`sum()` now types as a
union that includes `Decimal`). Unblocks Dependabot #154.
Expand Down
4 changes: 2 additions & 2 deletions src/project_x_py/sessions/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Date: 2025-08-28
"""

from datetime import UTC, date, datetime, time
from datetime import UTC, date, datetime, time, tzinfo
from typing import Any

import polars as pl
Expand All @@ -34,7 +34,7 @@ class SessionFilterMixin:
CACHE_TTL_SECONDS = 3600 # Cache time-to-live in seconds

# Cached timezone object for performance
_market_tz = None
_market_tz: tzinfo | None = None

def __init__(
self,
Expand Down
26 changes: 13 additions & 13 deletions src/project_x_py/statistics/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,25 +608,25 @@ async def _score_resources(self, stats: ComprehensiveStats) -> float:
"memory_usage_percent", memory_stats.get("usage_percent", 0.0)
)

if memory_usage_percent <= self.thresholds.memory_usage_excellent: # type: ignore[operator]
if memory_usage_percent <= self.thresholds.memory_usage_excellent:
memory_score = 100.0
elif memory_usage_percent <= self.thresholds.memory_usage_good: # type: ignore[operator]
elif memory_usage_percent <= self.thresholds.memory_usage_good:
ratio = (
memory_usage_percent - self.thresholds.memory_usage_excellent # type: ignore[operator]
memory_usage_percent - self.thresholds.memory_usage_excellent
) / (
self.thresholds.memory_usage_good
- self.thresholds.memory_usage_excellent
)
memory_score = 100.0 - (ratio * 20.0)
elif memory_usage_percent <= self.thresholds.memory_usage_warning: # type: ignore[operator]
ratio = (memory_usage_percent - self.thresholds.memory_usage_good) / ( # type: ignore[operator]
elif memory_usage_percent <= self.thresholds.memory_usage_warning:
ratio = (memory_usage_percent - self.thresholds.memory_usage_good) / (
self.thresholds.memory_usage_warning
- self.thresholds.memory_usage_good
)
memory_score = 80.0 - (ratio * 40.0)
elif memory_usage_percent <= self.thresholds.memory_usage_critical: # type: ignore[operator]
elif memory_usage_percent <= self.thresholds.memory_usage_critical:
ratio = (
memory_usage_percent - self.thresholds.memory_usage_warning # type: ignore[operator]
memory_usage_percent - self.thresholds.memory_usage_warning
) / (
self.thresholds.memory_usage_critical
- self.thresholds.memory_usage_warning
Expand Down Expand Up @@ -984,38 +984,38 @@ async def _check_resource_alerts(
"memory_usage_percent", memory_stats.get("usage_percent", 0.0)
)

if memory_usage_percent >= self.thresholds.memory_usage_critical: # type: ignore[operator]
if memory_usage_percent >= self.thresholds.memory_usage_critical:
alerts.append(
{
"level": AlertLevel.CRITICAL.value,
"category": "resources",
"message": f"Critical memory usage: {memory_usage_percent:.1f}%",
"metric": "memory_usage_percent",
"current_value": memory_usage_percent, # type: ignore[typeddict-item]
"current_value": memory_usage_percent,
"threshold": self.thresholds.memory_usage_critical,
"recommendation": "Immediately review memory leaks and restart if necessary",
}
)
elif memory_usage_percent >= self.thresholds.memory_usage_warning: # type: ignore[operator]
elif memory_usage_percent >= self.thresholds.memory_usage_warning:
alerts.append(
{
"level": AlertLevel.DEGRADED.value,
"category": "resources",
"message": f"High memory usage: {memory_usage_percent:.1f}%",
"metric": "memory_usage_percent",
"current_value": memory_usage_percent, # type: ignore[typeddict-item]
"current_value": memory_usage_percent,
"threshold": self.thresholds.memory_usage_warning,
"recommendation": "Monitor memory trends and consider implementing cleanup routines",
}
)
elif memory_usage_percent >= self.thresholds.memory_usage_good: # type: ignore[operator]
elif memory_usage_percent >= self.thresholds.memory_usage_good:
alerts.append(
{
"level": AlertLevel.WARNING.value,
"category": "resources",
"message": f"Elevated memory usage: {memory_usage_percent:.1f}%",
"metric": "memory_usage_percent",
"current_value": memory_usage_percent, # type: ignore[typeddict-item]
"current_value": memory_usage_percent,
"threshold": self.thresholds.memory_usage_good,
"recommendation": "Review memory usage patterns and optimize data structures",
}
Expand Down
Loading
Loading