Target Python 3.11 in ruff and ty for cli, core, mcp_server, platform_api, cookiecutter

With ruff target-version py310 and ty python-version 3.10, both tools
reject an unconditional `import tomllib`: ty reports it as unresolved
(exit 1) and ruff's isort classifies it as third-party. Raise the targets
in the projects that now import tomllib directly, and in the root
ruff.toml that governs dev_install.py.

- ruff target-version = "py311" and ty python-version = "3.11" in cli,
  core, mcp_server, platform_api, and cookiecutter; root ruff.toml
  target-version = "py311"
- UP042: OutputMode, ChartLifecycle, MCPType, and HTTPMethod become
  StrEnum; every consumer uses .value or == comparisons, so only str()
  and format() output change
- UP017: datetime.timezone.utc -> datetime.UTC (ruff autofix) in the cli
  dispatchers, the cli test generator, and a core test
This commit is contained in:
dlee-bq
2026-10-24 01:12:31 -07:00
parent 42fc2838f1
commit cad1fdcab5
14 changed files with 30 additions and 31 deletions

View File

@@ -3,6 +3,7 @@
from __future__ import annotations
from dataclasses import dataclass
from datetime import UTC
from typing import TYPE_CHECKING, Any
from openbb_cli.codegen.pydantic_gen import safe_field_name
@@ -288,7 +289,7 @@ def _spec_supplied_value(param: dict[str, Any]) -> Any:
def _refresh_date_shape(name: str, value: Any) -> Any:
"""Replace an aged date-shaped string with an equivalent current date."""
import re
from datetime import date, datetime, timedelta, timezone
from datetime import date, datetime, timedelta
if not isinstance(value, str):
return value
@@ -298,7 +299,7 @@ def _refresh_date_shape(name: str, value: Any) -> Any:
today = date.today()
return str(today - timedelta(days=30) if is_start else today)
if re.fullmatch(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?", value):
now = datetime.now(timezone.utc).replace(microsecond=0)
now = datetime.now(UTC).replace(microsecond=0)
chosen = (now - timedelta(days=30)) if is_start else now
return chosen.isoformat().replace("+00:00", "Z")
return value