Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> we never had a typing error in production

Python (currently) doesn't actually check actual types are per their annotations. Do you mean that you rely on, say, your IDE to do static analysis to ensure everything's lined up, or that just by virtue of having annotations, your team can reason about things more easily?

That's one thing I don't really like about type annotations in Py3.5+, unless you run it through a static analyser or have an IDE that understands them, they're effectively just noise. As such, I have mypy running through Syntastic, in Vim, and while not perfect it's a vast improvement over non-annotated Python.



Regarding typing errors in production, I meant that we never encountered an error that could have been directly prevented by a Java-like static type checker[1], e.g., a function with an int parameter that was called with a string argument.

We use types as a documentation tool so the noise you are talking about is actually very useful to us. When someone unfamiliar with the code wants to call a function, a quick look at the signature is usually enough now that we use type annotations. Before that, we provided that information in a docstring, which was more verbose so longer to write and longer to read.

We found PyCharm to offer a better out of the box validation experience than mypy (less configuration), but it's not perfect, i.e., we still see occasional false negatives and false positives. Ultimately, we did not include type checking in our build pipeline, but as the tooling becomes more mature, we will definitively revisit that decision.

[1] I know other languages have more powerful type systems that may have prevented some errors we encountered, but I don't have enough experience with these type systems applied to large systems to comment on that.


>Regarding typing errors in production, I meant that we never encountered an error that could have been directly prevented by a Java-like static type checker[1], e.g., a function with an int parameter that was called with a string argument.

That's because your devs had already suffered this bug in their test runs once too many times, and killed it before it got to production.

That, and luck.


I agree. That is why I mentioned our large test suite in my first comment.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: