Hacker News new | ask | show | jobs
by kroolik 1229 days ago
This is purely subjective. First of all, I prefer putting type hints everywhere. PyCharm helps reminding one in a lot of cases.

If there is a bug and somebody passes invalid type to my function, I would just fix it and move on.

Very often both None and empty list are not an interesting case and I return early. Thus `not users` makes sense.

There are cases, though, when None means a sane default should be used instead and you can't use default argument values due to mutability. In these cases `users is None` makes perfect sense.

There are also cases I explicitly check for True and False - tests. In such cases I wouldn't rely on truthy/falsy values and assert True and False values by reference.

Having said that, its all subject ive. You like this style, some one else likes other style. What ultimately matters are two things: automatic formatters and consistency.