4 ms·
Well, a python return type doesn’t really mean anything except to a type checker.
by nopenopenopeno 5y ago
Well, a python return type doesn’t really mean anything except to a type checker.
- willcipriano 5y agoRun mypy on it and see if it complains. If it does I think it will even tell you what type is being emitted instead.
- nopenopenopeno 5y agoThe question wasn’t what mypy will do. The question was what type will the function return.
- willcipriano 5y agomypy error: function 'x' returns type 'y' expected type 'z' I don't recall the exact message but I think it will emit something along those lines.
- comonoid 5y agoThe question wasn’t what mypy will do. The question was what type will the function return.
- deleted 5y ago[deleted]
- p_j_w 5y agoThat was my first thought as well. If someone asked me that during an interview, I might assume the type annotation for the return type was something meant to throw me off.
- indymike 5y agoThe value being returned in the correct type is especially important in languages without static type checking. The next line may try to add the dictionary you returned to an integer or something crazy.