News for hackers. Stuff that matters.
Re:Poll: Is the leetcode grind necessary to land a high payi... by nopenopenopeno on Thursday January 27, 2022 @08:54AM (#30100553)
Well, a python return type doesn’t really mean anything except to a type checker.
Re:Poll: Is the leetcode grind necessary to land a high payi... by p_j_w on Thursday January 27, 2022 @12:54PM (#30103704)
That 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.
Re:Poll: Is the leetcode grind necessary to land a high payi... by indymike on Thursday January 27, 2022 @12:55PM (#30103723)
The 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.
Re:Poll: Is the leetcode grind necessary to land a high payi... by willcipriano on Thursday January 27, 2022 @09:20AM (#30100852)
Run mypy on it and see if it complains. If it does I think it will even tell you what type is being emitted instead.
Re:Poll: Is the leetcode grind necessary to land a high payi... by nopenopenopeno on Thursday January 27, 2022 @09:56AM (#30101293)
The question wasn’t what mypy will do. The question was what type will the function return.
Re:Poll: Is the leetcode grind necessary to land a high payi... by willcipriano on Thursday January 27, 2022 @10:00AM (#30101337)
mypy 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.

Re:Poll: Is the leetcode grind necessary to land a high payi... by comonoid on Friday January 28, 2022 @05:15AM (#30112802)
The question wasn’t what mypy will do. The question was what type will the function return.