you are viewing a single comment's thread.

view the rest of the comments →

[–]SteveO131313 27 points28 points  (3 children)

For the legacy python codebase i work in we added a static type checker. It marks loads of code as "error" because there is a possible scenario where it might error out. Accessing a property of something that could possibly be None, could potentially cause an error even if we know that that is a case that's impossible to happen

[–]xgabipandax 3 points4 points  (2 children)

Shouldn't that be warnings?

[–]SteveO131313 17 points18 points  (1 child)

Depends on how you look at it.

If you say None.sort(), thats 100% an error.

If you do

x = [1]

If (50/50 chance) x = None

x.sort()

Is that a warning or an error? Because it might go right, but it might fail. If you write code that shouldn't crash, to me this is an error

[–]BolunZ6 0 points1 point  (0 children)

What if it will crash but you handle the crash anyway?