@schmonz@octodon.social
For me, complexity and size vs. time. If it's a smallish bit of functionality I've written several times before (previous employers, etc), I can probably bash it out again in less time than it takes to find a 3rd-party lib, check its licensing, and review its codebase and history to figure out if it's likely to be secure and well-implemented.
If it's a big chunk of work and I know of a 3rd-party package that I know is suitable - FastAPI, Pydantic, etc - I'll use that.