|
|
|
|
|
by hbrn
1275 days ago
|
|
> I don't have to try to guess what something is, based on its name It's probably just a bad example, but in case it isn't: Sounds like you ended up at the same place. You went from guessing what is some_api.get_results(), based on it's name, to guessing what is SomeAPIResult, also based on it's name. If some_api is your library, then you could have just added type hints to get_results() and let type inference do it's job. If it's a third party library, then using your custom SomeAPIResult means that code is becoming alien to other engineers that worked with that library in the past. It might be worth it, but it's definitely controversial. You probably should've done it with stubs anyway. |
|
I disagree. It’s not a guess, it is precisely what it is, where the variable name is free to betray me. A sane IDE/linter will tell me if my local assumption is incorrect, where a variable called result_SomeAPIResult relies on an assumed, possibly ancient, state of reality.