4 ms·
Sorry but why wouldn't type hints add anything to that example? Type hints are usually there to help the user of the function, not to help with internal impleme
by Too 7y ago
Sorry but why wouldn't type hints add anything to that example? Type hints are usually there to help the user of the function, not to help with internal implementation.
Just add word: str to all the functions and it will make it impossible to accidentally call any function with an invalid type. Especially the known(words) function is easy to misuse by providing a single string instead of a Iterable[str]. Iterable is a generic btw and will support both sets, lists and other similar types without any obscene type game. mypy also supports static duck typing with Protocols.