News for hackers. Stuff that matters.
Re:Python's Type Checking Renaissance by avolcano on Tuesday January 26, 2021 @11:26AM (#25917657)
I'm excited about Python's typing potential. I recently rewrote an API from TypeScript to Kotlin since I am fairly unhappy with the server-side TS ecosystem, but ran across https://github.com/tiangolo/fastapi when exploring options and really dig it - seems to be by _far_ the lowest-ceremony way to make an HTTP API with static types that integrate with parsing/validation (something TypeScript is still really bad at, unless you bring your own runtime typing libraries...).
Re:Python's Type Checking Renaissance by manojlds on Tuesday January 26, 2021 @11:29AM (#25917708)
More specifically, Pydantic. It's great!
Re:Python's Type Checking Renaissance by mattanimation on Tuesday January 26, 2021 @01:33PM (#25919469)
FastAPI got me turned onto Pydantic, both are awesome!
Re:Python's Type Checking Renaissance by marliechiller on Wednesday January 27, 2021 @04:32AM (#25926091)
I use pydantic all over the place now. FastAPI was what introduced it to me. Its really nice to be able to take advantage of the autocompletion when utilizing pydantic models rather than a straight dictionary. Now, in a lot of instances I use the pydantic models instead of dictionaries as it feels more explicit
Re:Python's Type Checking Renaissance by avolcano on Tuesday January 26, 2021 @11:33AM (#25917761)
Ah, thanks, I hadn't realized that's the underlying library! Runtime validation of types is absolutely the largest missing feature from TypeScript, IMO, so Pydantic is really impressive to me.
Re:Python's Type Checking Renaissance by ensignavenger on Tuesday January 26, 2021 @11:48AM (#25917996)
Yes, I have been using Pydantic with my Django projects, and it is great!
Re:Python's Type Checking Renaissance by giovannibonetti on Tuesday January 26, 2021 @06:36PM (#25922348)
Have you taken a look at https://rocket.rs?
Re:Python's Type Checking Renaissance by sli on Tuesday January 26, 2021 @11:30PM (#25924305)
Rocket is nice but I had a much, much better experience with Warp[0]. I ran into a lot of roadblocks with Rocket, especially with stuff like JWT and working with databases. No such issues with Warp.

0: https://github.com/seanmonstar/warp

Re:Python's Type Checking Renaissance by avolcano on Wednesday January 27, 2021 @03:25AM (#25925655)
I'm curious about both, and Rust for APIs in general. While I'm excited by the expressiveness of the language (compared to e.g. Go) and how robust the type system is. Right now, though it feels like a bit too much of a barrier both in terms of learning the language and the smaller ecosystem right now (this article covers a lot of my concerns: https://macwright.com/2021/01/15/rust.html). Still keeping an eye on it and would gravitate towards it if I had a smaller service that needed particularly high performance.