PacktPublishing / Building-Data-Science-Applications-with-FastAPI

Building Data Science Applications with FastAPI, Published by Packt
MIT License
306 stars 157 forks source link

Refering to python built-in `id` instead of `comment.post_id` in HTTPException? #11

Closed gitgithan closed 2 years ago

gitgithan commented 2 years ago

I found this happening in 2 places by searching detail=f"Post in vscode.

  1. https://github.com/PacktPublishing/Building-Data-Science-Applications-with-FastAPI/blob/main/chapter6/sqlalchemy_relationship/app.py#L124
  2. https://github.com/PacktPublishing/Building-Data-Science-Applications-with-FastAPI/blob/main/chapter6/tortoise_relationship/app.py#L80

On the front-end, the interpolated string looks like it's printing some information about a function instead of the post id. I guess the python built-in id was used when it should be comment.post_id?

frankie567 commented 2 years ago

Whoops! That's indeed a mistake on my part!

You're right the correct way would be:

detail=f"Post {comment.id} does not exist"

I'll fix this right away and coordinate a fix with Packt!

Thank you for your help 🙏

frankie567 commented 2 years ago

Fixed in https://github.com/PacktPublishing/Building-Data-Science-Applications-with-FastAPI/commit/34d40b4779fc9bcd1a12d6f425a8f78db02a25bd