Skip to content

Latest commit

 

History

History
66 lines (49 loc) · 2 KB

File metadata and controls

66 lines (49 loc) · 2 KB

Python FastAPI And pytest Example

This example shows the shape of a source-checkout dogfood flow for Python FastAPI and pytest repositories. It uses committed fixture paths as examples, but the commands are intended for any repository you choose to initialize.

Example Source Shapes

FastAPI route:

from fastapi import APIRouter

router = APIRouter()

@router.get("/health")
def health():
    return {"ok": True}

pytest test:

def test_health_response(client):
    response = client.get("/health")
    assert response.status_code == 200

RepoGrammar can form bounded families only when enough compatible exact-anchor evidence exists. Low-support examples, ambiguous fixtures, dynamic imports, runtime dependency injection, stale evidence, and framework magic remain UNKNOWN.

Run Against A Repository

export REPOGRAMMAR_TARGET=/path/to/python/repo
cd "$REPOGRAMMAR_TARGET"
repogrammar init
repogrammar families
repogrammar find --project . --token-budget 8000 path/to/routes.py
repogrammar find --project . --token-budget 8000 path/to/test_routes.py

For metadata plus bounded source spans:

repogrammar find --project . --token-budget 8000 --include-source-spans path/to/routes.py

What To Look For

  • A FastAPI route family should mention framework-family support such as framework:fastapi.route only when compatible exact anchors are present.
  • A pytest family should preserve fixture ambiguity as UNKNOWN when fixture binding is not unambiguous.
  • The read_plan lists repo-relative spans to inspect before editing.
  • Default output does not include source snippets.
  • check results remain advisory where runtime equivalence is unproven.

Negative Cases To Preserve

  • Dynamic route decorators or route prefixes must not become support evidence.
  • Custom pytest wrappers must not be treated as native runner support.
  • Ambiguous or plugin-provided fixtures must remain typed UNKNOWN.
  • Low-support examples should return UNKNOWN instead of a weak family claim.