Catch missing awaits in async code with ty

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Infrastructure
    • None
    • Python Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      Investigated whether ty's unused-awaitable rule catches missing
      {{await}}s that mypy's strict config misses (full write-up:
      https://gist.github.com/blink1073/a9fe43fbb2643b12ab4472836e77ee40). It found 2 real
      bugs, fixed separately in PYTHON-5975, plus 14 expected false positives from the
      @require_sync convention. mypy's own unused-coroutine check misses these
      because no-untyped-def is disabled for test code. This ticket wires up ty as an
      ongoing check so future missing-awaits are caught automatically.

      Definition of done


      * ty check --ignore all --error unused-awaitable wired up as a just recipe
      and in CI/pre-commit, scoped to pymongo, gridfs, bson, test
      * The 14 known @require_sync false positives suppressed without changing their
      behavior
      * Check passes clean

      Pitfalls


      * ty isn't a project dependency yet; decide between uvx ty (no pin) or
      adding it to a dependency group
      * Keep the check scoped to unused-awaitable. The related invalid-await rule
      also fired, including in real source, but overlaps with existing
      type: ignore[misc] suppressions and needs separate verification (out of scope)
      * Don't suppress the 14 @require_sync false positives by adding await;
      that's intentional dead code matching the generated sync test file

            Assignee:
            Unassigned
            Reporter:
            Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: