강의

멘토링

커뮤니티

Inflearn Community Q&A

tlsfkaus48624264's profile image
tlsfkaus48624264

asked

Python Concurrent Programming: From Data Collection to Web Development (feat. FastAPI, async, await)

TypeError: field Config is defined without type annotation

Resolved

Written on

·

243

0

'FastAPI + MongoDB ODM 셋업' 강의 중 book.py 파일을 만든 뒤 서버를 실행할 때 아래와 같은 에러 메시지가 노출됩니다.

 

TypeError: field Config is defined without type annotation

 

Config에 type annotation이 정의되지 않았다고 하는데, 타입을 정의하거나 클래스 이름을 바꿔보는 등의 방법을 적용해보아도 같은 에러코드가 노출되고 있어 문의드립니다.

 

제가 사용하고 있는 환경의 python은 3.8버전이며, odmantic 등 라이브러리는 최신 버전을 사용하고 있습니다.

python동시성FastAPI

Answer 1

0

odmantic의 모델링 방식이 바뀐거 같습니다. 아래와 같이 코드를 수정했더니 해결됐습니다.

 

# book.py

# 강의에 나오는 코드
class Config:
    collection = "books"

# 수정한 코드
model_config = {"collection": "books"}
tlsfkaus48624264's profile image
tlsfkaus48624264

asked

Ask a question