Tom Ritchford
Jun 24, 2024

--

But I would reject this pull request, because your type hints are all wrong.

Why must num_list be a list? Why couldn't it be a tuple or some other sequence of numbers? Use typing.Sequence instead.

Why Union[int, float]? This won't work if you're using numbers from fractions, numpy or pytorch: use numbers.Number instead, that's exactly what that module is about.

Finally, appending to a list in a loop is inefficient: use

return [i + num for i in num_list]

Sorry to be so direct, but if you’re going to give advice, give the correct advice.

--

--