Skip to content

IP-7068: [compose] dishka 기반 auto-wiring route class 팩토리 제공#535

Merged
novdov merged 7 commits intomainfrom
ip-7068
Mar 9, 2026
Merged

IP-7068: [compose] dishka 기반 auto-wiring route class 팩토리 제공#535
novdov merged 7 commits intomainfrom
ip-7068

Conversation

@novdov
Copy link
Copy Markdown
Contributor

@novdov novdov commented Mar 9, 2026

목적

dependency-injector의 명시적 와이어링으로 인한 연쇄 수정 문제를 해소하기 위해, fastapi_example에 있던 dishka 기반 auto-wiring route class 팩토리를 compose 모듈로 이동하여 공통으로 사용할 수 있도록 제공

변경 사항

  • compose.fastapi.dishka 모듈 추가
    • injected_route(container) 팩토리: container의 registry에서 해결 가능한 타입을 자동으로 FromDishka[Type]으로 변환하는 route class 생성
    • dishka optional dependency로 추가하여 conditional export 제공
  • 유닛 테스트 8개 추가
    • resolvable 타입 변환, 비변환 타입(path param, Annotated, Union, 미어노테이션) 유지, 기본값 파라미터 변환, HTTP round-trip 검증
  • fastapi_example 전환
    • src/dependency/routing.py 삭제, compose.fastapi.injected_route 직접 사용으로 전환

Summary by CodeRabbit

릴리스 노트

  • 신기능

    • Dishka가 설치된 경우 사용할 수 있는 FastAPI용 의존성 주입 라우트 헬퍼(injected_route)를 공개하여 라우터 통합을 간편화
  • 테스트

    • 의존성 주입 통합 동작을 검증하는 포괄적인 단위 및 통합 테스트 추가
  • 의존성

    • Dishka를 옵션 의존성 및 개발용 의존성 그룹에 추가

novdov and others added 5 commits March 9, 2026 17:38
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@novdov novdov self-assigned this Mar 9, 2026
@linear
Copy link
Copy Markdown

linear bot commented Mar 9, 2026

IP-7068 [compose] dishka 기반 auto-wiring route class 팩토리 제공

배경

  • dependency-injector의 명시적 와이어링으로 인한 연쇄 수정 문제를 해소하기 위해 dishka 기반 auto-wiring이 필요
  • 레퍼런스 구현이 fastapi_example에 이미 존재하며, 이를 compose 모듈로 이동하여 공통으로 사용할 수 있도록 해야 함

목표

  • dishka 기반 injected_route 팩토리를 compose.fastapi 모듈에서 제공
  • example에서 compose 모듈의 구현을 직접 사용하도록 전환

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 9, 2026

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 3637a725-8a74-4070-b04e-4c4e406853f8

📥 Commits

Reviewing files that changed from the base of the PR and between d7d2389 and f61c019.

📒 Files selected for processing (1)
  • tests/fastapi/unit/test_injected_route.py

Walkthrough

compose.fastapi에 Dishka 통합용 엔트리인 injected_route가 도입되고 관련 명칭이 변경되었으며, 해당 기능을 선택적로드하도록 init.py가 수정되었습니다. dishka가 optional/dev 의존성으로 추가되고 통합 동작을 검증하는 단위 테스트와 예제가 업데이트되었습니다.

변경 사항

Cohort / File(s) 요약
API 이름 변경
compose/fastapi/dishka.py
함수 create_auto_wired_routeinjected_route, 클래스 AutoWiredDishkaRouteInjectedDishkaRoute로 명칭 변경. 내부 로직과 시그니처는 유지.
공개 내보내기 추가
compose/fastapi/__init__.py
compose.fastapi.dishkainjected_route를 try/except로 선택적 임포트하고, 사용 가능하면 __all__에 추가하도록 변경.
사용 예시 업데이트
examples/fastapi_example/src/user/entrypoint/router.py
from compose.fastapi import injected_route 추가 및 라우터 초기화에서 injected_route(container) 사용으로 변경.
의존성 업데이트
pyproject.toml
선택적 및 개발 의존성에 dishka>=1.9,<2 추가.
테스트 추가
tests/fastapi/unit/test_injected_route.py
injected_route의 타입 해석, 기본값 처리, DI 해상도 및 HTTP 라운드트립을 검증하는 단위 테스트 신규 추가.

시퀀스 다이어그램

sequenceDiagram
    participant Client as Client
    participant FastAPI as FastAPI App
    participant Route as InjectedDishkaRoute
    participant Container as Dishka Container
    participant Handler as Endpoint Handler

    Client->>FastAPI: HTTP 요청
    FastAPI->>Route: 라우트 핸들러 호출
    Route->>Container: 의존성(파라미터) 요청 (resolve)
    Container-->>Route: 인스턴스 반환
    Route->>Handler: 핸들러 호출 (주입된 인자 포함)
    Handler-->>Route: 응답 반환
    Route-->>FastAPI: 응답 전달
    FastAPI-->>Client: HTTP 응답
Loading

예상 코드 리뷰 소요 시간

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 새 이름 달고 길을 찾네
주입된 손길로 요청을 건네
테스트는 웃고 의존성은 손짓해
FastAPI와 Dishka, 함께 춤추네 🥕✨


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@pozalabs-workspace pozalabs-workspace bot added the Improvement New feature or request label Mar 9, 2026
novdov and others added 2 commits March 9, 2026 17:43
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@novdov novdov merged commit 1bd6797 into main Mar 9, 2026
5 checks passed
@novdov novdov deleted the ip-7068 branch March 9, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant