Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

chore: drop more pre-3.11 leftovers found in review (#2105)

Sameer Kadam8238001fadd4
diff --git a/docs_check.py b/docs_check.py
index ba0e7529..8b283111 100644
--- a/docs_check.py
+++ b/docs_check.py
@@ -165,21 +165,7 @@ def _() -> list[str]:
]
-# ── 7. No Python 3.9+ type syntax in code blocks ─────────────────────────────
-@check("No Python 3.9+ type syntax in code blocks (3.8 compat)")
-def _() -> list[str]:
- issues: list[str] = []
- for fpath in ALL_MD:
- in_block = False
- for i, line in enumerate(open(fpath, encoding="utf-8"), 1):
- if line.strip().startswith("```"):
- in_block = not in_block
- if in_block and re.search(r":\s*(list|dict|tuple|set)\[", line):
- issues.append(f"{fpath}:{i}: {line.rstrip()}")
- return issues
-
-
-# ── 8. index.md covers all 27 modules ────────────────────────────────────────
+# ── 7. index.md covers all 27 modules ────────────────────────────────────────
@check("All 27 modules present in index.md")
def _() -> list[str]:
modules = [
@@ -196,7 +182,7 @@ def _() -> list[str]:
return [m for m in modules if m not in index]
-# ── 9. JSX component tags are balanced in every page ─────────────────────────
+# ── 8. JSX component tags are balanced in every page ─────────────────────────
@check("All Mintlify JSX component tags are balanced")
def _() -> list[str]:
# Paired block-level components that must open and close.
@@ -226,7 +212,7 @@ def _() -> list[str]:
return issues
-# ── 10. Mintlify export succeeds (requires Node.js / npx) ────────────────────
+# ── 9. Mintlify export succeeds (requires Node.js / npx) ────────────────────
@check("Mintlify export builds without errors")
def _() -> list[str]:
npx = "npx.cmd" if sys.platform == "win32" else "npx"
diff --git a/semantica/context/global_retriever.py b/semantica/context/global_retriever.py
index 3a142010..9d105faf 100644
--- a/semantica/context/global_retriever.py
+++ b/semantica/context/global_retriever.py
@@ -895,10 +895,7 @@ class GlobalGraphRetriever:
)
for f in future_to_report:
f.cancel()
- try:
- executor.shutdown(wait=False, cancel_futures=True)
- except TypeError:
- executor.shutdown(wait=False)
+ executor.shutdown(wait=False, cancel_futures=True)
for future, rep in future_to_report.items():
if future not in completed_futures:
@@ -918,10 +915,7 @@ class GlobalGraphRetriever:
)
)
finally:
- try:
- executor.shutdown(wait=False, cancel_futures=True)
- except TypeError:
- executor.shutdown(wait=False)
+ executor.shutdown(wait=False, cancel_futures=True)
return all_points
diff --git a/semantica/ingest/ssrf.py b/semantica/ingest/ssrf.py
index 8fedcfba..b435b8c7 100644
--- a/semantica/ingest/ssrf.py
+++ b/semantica/ingest/ssrf.py
@@ -138,11 +138,7 @@ def parse_bool(value: Any, default: bool = False) -> bool:
def _shutdown_executor(executor: concurrent.futures.ThreadPoolExecutor) -> None:
"""Shut down *executor* without waiting for in-flight DNS lookups."""
- try:
- executor.shutdown(wait=False, cancel_futures=True)
- except TypeError:
- # cancel_futures was added in Python 3.9.
- executor.shutdown(wait=False)
+ executor.shutdown(wait=False, cancel_futures=True)
def _get_dns_executor() -> concurrent.futures.ThreadPoolExecutor:
diff --git a/semantica/normalize/__init__.py b/semantica/normalize/__init__.py
index 671cef89..e3fe7ce8 100644
--- a/semantica/normalize/__init__.py
+++ b/semantica/normalize/__init__.py
@@ -22,7 +22,7 @@ Entity Normalization:
Date/Time Normalization:
- Date Parsing: dateutil.parser.parse() with fallback to datetime.fromisoformat(), ISO format parsing, multiple format support
- - Timezone Normalization: UTC conversion using datetime.astimezone(), timezone-aware datetime handling, ZoneInfo integration (Python 3.9+), DST transition handling
+ - Timezone Normalization: UTC conversion using datetime.astimezone(), timezone-aware datetime handling, ZoneInfo integration, DST transition handling
- Relative Date Processing: Natural language parsing ("yesterday", "3 days ago", "2 weeks from now"), timedelta calculation, relativedelta for complex expressions, reference date-based calculation
- Temporal Expression Parsing: Complex temporal expressions, date range parsing ("from X to Y"), pattern matching, relative/absolute date detection
diff --git a/semantica/normalize/date_normalizer.py b/semantica/normalize/date_normalizer.py
index f433db7b..a835c207 100644
--- a/semantica/normalize/date_normalizer.py
+++ b/semantica/normalize/date_normalizer.py
@@ -252,7 +252,7 @@ class TimeZoneNormalizer:
- UTC conversion
- Timezone abbreviation processing
- Daylight saving time handling
- - ZoneInfo integration (Python 3.9+)
+ - ZoneInfo integration
Example Usage:
>>> tz_normalizer = TimeZoneNormalizer()
@@ -280,8 +280,8 @@ class TimeZoneNormalizer:
"""
Normalize datetime to target timezone.
- This method converts a datetime object to the specified timezone,
- using ZoneInfo if available (Python 3.9+), or falling back to UTC.
+ This method converts a datetime object to the specified timezone with
+ ZoneInfo. If the conversion fails, the datetime comes back unconverted.
Args:
datetime_obj: Datetime object to normalize
@@ -299,7 +299,10 @@ class TimeZoneNormalizer:
datetime_obj = datetime_obj.replace(tzinfo=timezone.utc)
return datetime_obj.astimezone(target_tz)
except Exception:
- # Fallback if zoneinfo not available
+ # zoneinfo is always available (stdlib on 3.11+). This falls back on
+ # any failure (an unknown, malformed or non-str timezone name, or a
+ # conversion overflow) and returns the datetime unconverted; a naive
+ # input may come back tagged UTC.
return datetime_obj
def convert_to_utc(
diff --git a/tests/test_llm_typesafe.py b/tests/test_llm_typesafe.py
index e6d9fd44..36125229 100644
--- a/tests/test_llm_typesafe.py
+++ b/tests/test_llm_typesafe.py
@@ -8,7 +8,7 @@ from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock
import pytest
-import toml
+import tomllib
import semantica.llms.typesafe as typesafe_module
from semantica.context import Decision
@@ -563,7 +563,8 @@ def test_result_round_trips_as_decision_provenance():
def test_pyproject_pins_reviewed_sdk_line_and_includes_aggregate_extra():
- pyproject = toml.load(Path(__file__).resolve().parents[1] / "pyproject.toml")
+ with open(Path(__file__).resolve().parents[1] / "pyproject.toml", "rb") as f:
+ pyproject = tomllib.load(f)
extras = pyproject["project"]["optional-dependencies"]
assert extras["llm-typesafe"] == [
@@ -686,7 +687,8 @@ async def test_real_owned_sdk_async_dispatch_and_model_precedence(
def test_typesafe_ci_pin_and_hashes_match_uv_lock():
root = Path(__file__).resolve().parents[1]
- lock = toml.load(root / "uv.lock")
+ with open(root / "uv.lock", "rb") as f:
+ lock = tomllib.load(f)
package = next(p for p in lock["package"] if p["name"] == "typesafe-sdk")
requirements = (root / "requirements-ci.txt").read_text()
entry = re.search(
diff --git a/tests/test_python_support_policy.py b/tests/test_python_support_policy.py
index a132494e..04f08bb8 100644
--- a/tests/test_python_support_policy.py
+++ b/tests/test_python_support_policy.py
@@ -10,7 +10,7 @@ import re
from pathlib import Path
import pytest
-import toml
+import tomllib
import yaml
from semantica import cli
@@ -20,7 +20,8 @@ ROOT = Path(__file__).resolve().parent.parent
@pytest.fixture(scope="module")
def pyproject():
- return toml.load(ROOT / "pyproject.toml")
+ with open(ROOT / "pyproject.toml", "rb") as f:
+ return tomllib.load(f)
def _range(requires_python: str):