5 ms·
From a personal point of view, FastAPI and Pydantic are some of the greatest additions to the Python ecosystem lately. Apart from that, FastAPI is currently th
by polyrand 5y ago
From a personal point of view, FastAPI and Pydantic are some of the greatest additions to the Python ecosystem lately.
Apart from that, FastAPI is currently the top 3 web framework according to the Python developer survey[0]. I think having such a breaking change is a serious issue.
[0] https://www.jetbrains.com/lp/python-developers-survey-2020/ https://www.jetbrains.com/lp/python-developers-survey-2020/
- darkteflon 5y agoWhat do you like about FastAPI and Pydantic?
- SirSourdough 5y agoFrom the perspective of someone who mostly dabbles in creating APIs for my own use: - Auto-generated docs and simple front end for your API allow you to examine and interact with your endpoints with essentially no added work or tools - Feature rich and performant - Tight pairing with Pydantic makes specifying and validating data models easy Basically, FastAPI (and pydantic under the hood) just abstracts away a lot of the work you would need to do to build a relatively fully-featured API on your own, and adds quality of life features that one generally couldn’t justify building/setting up for themselves, especially for smaller projects. Plus, the docs are solid and it’s a pretty simple library to get started with. It’s very much been an “it just works” library for me in most cases.
- qbasic_forever 5y agoI like that FastAPI has documentation meant to be read from beginning to end. It walks you through not only the how but the why of core design decisions, and even dives into ancillary things like pydantic. This is in sharp contrast to most python packages of modest size where IMHO the bare minimum effort is put into technical docs. Usually you get something using a 10+ year old Sphinx template that hasn't changed for modern devices, and no description of usage is more than a trite paragraph (i.e. the attention span of a developer writing a docstring).
- KptMarchewa 5y agoAgreed. This is an issue not only in Python. How many Java packages documentation is just generated Javadoc?
- ggregoire 5y agoAmong other things, having the query and body parameters automatically validated from the type hints defined on the endpoint and having the corresponding HTTP error and error message automatically added to the response is a huge time saving. Also, the doc is great and the maintainers are very helpful on github.
- polyrand 5y agoOther people have already mentioned great things about FastAPI (documentation, data validation, good performance, easy to use, etc). There's also a lot to love about Pydantic alone. For me, the best thing about Pydantic is that I get performant, strongly validated objects. When I create Python apps, I try to make sure functions receive and return Pydantic models. That way, if the function does not fail, I'm 100% sure about the data coming in and out. It also saves me from writing many if statements. Those Pydantic objects can also be dynamically created without losing the data validation parts. By using it, I feel very "secure" about my types and objects, but keeping the simplicity of Python for my whole app.
- travisjungroth 5y agoHave you written it with an ORM backed app? I’m curious if you put the business logic on the Pydantic models and keep the ORM small, or put the logic on the ORM and treat Pydantic like a serializer. Personally, I’d rather work with Pydantic models than ORM.
- sandGorgon 5y agothere's a way to autogenerate pydantic and ORM (sqlalchemy) models from the same python dataclasses. here's a fully functional gist - https://gist.github.com/sandys/671b8b86ba913e6436d4cb22d04b135f https://gist.github.com/sandys/671b8b86ba913e6436d4cb22d04b1...
- madkat 5y agoWe use SQLAlchemy as the ORM layer, but it's very small and most of the work is done with the Pydantic models. It works quite nicely, despite that we loose change tracking, but SQLAlchemy got us covered with merging models.
- polyrand 5y agoI don’t use ORMs. For bigger apps, I use asyncpg and map the results to Pydantic objects. I write raw SQL and keep Pydantic objects as the “source of truth” throughout my app.