[langgraph-*-mongodb] pytest floor emits ~2000 ast deprecation warnings on py3.13; those APIs are removed in 3.14

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: ABX
    • None
    • Python Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Goal

      Raise the pytest floor in langgraph-checkpoint-mongodb and langgraph-store-mongodb. At their declared minimum versions these libs emit ~1,000-2,000 deprecation warnings per run on Python 3.13, and the API being warned about has already been removed in Python 3.14 — so this is a leading indicator of a hard failure, not cosmetic noise.

      Blocked by

      Nothing. Discovered while validating INTPYTHON-1066; both libs pass today, so this is not urgent.

      Symptom

      Running the minimum-version unit suite (as INTPYTHON-1066's step will) on Python 3.13, against main at 006027e:

      Lib py3.11 py3.13
      langgraph-checkpoint-mongodb 17 passed, 1 warning 17 passed, 1,084 warnings
      langgraph-store-mongodb 23 passed, 0 warnings 23 passed, 2,069 warnings

      Root cause

      Both libs declare "pytest>=7.2.1", so --resolution=lowest-direct installs exactly pytest 7.2.1. Its assertion-rewriting module uses ast node classes that Python deprecated in 3.12.

      Essentially all of the volume comes from three lines in one file:

      .venv/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:945: 111 warnings
      .venv/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:948: 111 warnings
      .venv/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:1058: 76 warnings
      

      Distinct messages, by frequency:

      DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
      DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead
      DeprecationWarning: ast.NameConstant is deprecated and will be removed in Python 3.14; use ast.Constant instead
      

      The warning text is literal about the deadline, and it has passed:

      $ python3.14 -c "import ast; ast.Str"
      AttributeError: module 'ast' has no attribute 'Str'
      

      Implication: when these two libs gain Python 3.14 support, pytest 7.2.1 at the floor will not warn — it will crash on import of the assertion rewriter. The 3.13 warning surge is the same defect, one version earlier and still survivable.

      Second, smaller pattern (checkpoint lib only)

      ResourceWarning: Unclosed MongoClient opened at:   (6 occurrences)
      ResourceWarning: unclosed event loop                (asyncio/events.py)
      

      These are ours, not upstream's — test fixtures leaking MongoClient instances and an event loop. Low priority, but worth cleaning while in the area, since ResourceWarning is the category most likely to mask a real leak.

      Proposed fix, and a complication

      Raising the pytest floor removes the entire ast category. Verified on langgraph-store-mongodb, py3.13, all other deps at their floors:

      pytest Result
      7.2.1 (current floor) 23 passed, 2,069 warnings
      8.0.0 23 passed, 0 warnings
      8.4.2 16 passed, 7 errors

      So pytest>=8.0.0 is the target, but the floor cannot simply be opened to the latest: 8.4.2 fails against pytest-asyncio at its own floor of 0.21.1, inside _asyncgen_fixture_wrapper / _perhaps_rebind_fixture_func — the same class of pytest/pytest-asyncio incompatibility already hit in langchain-mongodb-deepagents-vfs under INTPYTHON-1054, which needed pytest-asyncio>=0.23.8.

      The two floors therefore have to move together. Suggested starting point for both libs, to be confirmed by bisect:

      "pytest>=8.0.0",
      "pytest-asyncio>=0.23.8",
      

      Steps

      1. Bisect the lowest (pytest, pytest-asyncio) pair that passes cleanly for each lib on 3.11 and 3.13.
      2. Raise both floors; regenerate uv.lock.
      3. Confirm the minimum-version suite is warning-free, or close to it, on both interpreters.
      4. Separately, fix the unclosed MongoClient / event loop in the checkpoint lib's fixtures.

      Acceptance criteria

      • Minimum-version unit runs on 3.13 emit no ast.Str/ast.Num/ast.NameConstant deprecation warnings for either lib.
      • Both libs still pass at minimum versions on 3.11 and 3.13.
      • No ResourceWarning: Unclosed MongoClient in the checkpoint lib.

      Notes

      • Neither lib sets filterwarnings = ["error"], which is the only reason this has been invisible. langchain-mongodb does set it, and was checked — it does not trip on 3.13.
      • Verification basis: detached git worktree at main (006027e), uv sync -resolution=lowest-direct followed by uv run --no-sync pytest, against a live local MongoDB. The -no-sync is required because of the CI no-op fixed in INTPYTHON-1066.

            Assignee:
            Casey Clements
            Reporter:
            Casey Clements
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: