However, if I had a choice, rather than use typehints in python, I would much rather just use a statically typed language. Short, tiny scripts in python? Sure. Anything that grows or lives a long time? Use something where the compiler helps you out.
That's your problem right there. Why are random callers sending whatever different input types to that function?
That said, there are a few existing ways to define that property as a type, why not a protocol type "Indexable"?
My advice is look at the numbers very carefully and choose something that is (below) or fits your budget. Sudden financial issues like the loss of a job or new vehicle purchase can put a big strain on all this.
You’re driving down the street trying to decide which restaurant to stop at (or scanning through the radio trying to decide which song to stop on).
If you stop at the first, there’s a good chance something better is ahead. But if you wait too long then you risk getting stuck with something you don’t really like (the problem assumes you can’t go back).
If I remember correctly, mathematically you skip the first 1/3, but keep track of your “best”. Then stop at the next option that’s >= than your current best or maybe the next thing you like.
With respect to skis, I have the same issue every year with a ride on lawn mower. Do I just pay someone weekly or buy one outright and do it myself? In this case I loathe mowing, so I don’t mind paying. But with skis it’s a question of just how much I’ll ski after this stretch, regardless of whether or not this stretch is 1 or 20 days. Because there are additional costs (and benefits) to ownership beyond the initial purchase.
I bought mine, ran great for 4 years, then ran into a bunch of trouble, which made me recognize the other hidden cost of ownership is simply just maintenance. A very expensive mower just sitting there, nearest potential repair shop far away, no idea how I'd even get it there let alone the cost. And if I decide I don't want it, I've got to pay to get rid of it now too.
Luckily I was able to watch a bunch of youtube videos and order myself some parts to get it up and running again, but definitely sunk quite a bit of time and energy into it.
Yes, if they aren't in the code, it just means the programmer has figure out and carry that around mentally when reading or writing code.