Am Mittwoch, dem 03.04.2024 um 17:55 +0000 schrieb Jeremy Stanley:
It's hard to say lack of typing is a "bad coding practice" for code that was written (as much as a decade) before Python standardized on any sort of type annotation scheme. Not getting into judgement on whether typing is a real improvement in the language, but don't fault an antique radio for using tubes instead of transistors.
No, it really isn't hard to say it. Because I judge it now, with todays standards. Because we - hopefully - have learned and improved some things in information technology since 2010. I can - of course - respect it from the view of history. I don't blame the code or the authors. They had no better tools. They did the best that they could. But today we do have better tooling, and we can improve the code. That's why we are working on openstack, after all. PEP 484 was standardized in May 2015, almost 9 years ago. [1] Work on mypy started in 2012[2] and v0.1.0 was - as far as I remember - already usable almost 10 years ago[3]. Yes, parts of openstack are older than that and it was good for the time it was written in. But software should evolve if it wants to stay relevant. Yes don't follow every "hype" cycle, I've also seen some of those (anybody remember the "dumb terminal-
mainframe->powerful pc client->more powerful server" hypecycle?). But don't confuse actual improvements with hype, which admittedly can be hard sometimes, especially if something is new.
It's okay in 2015 to say "ah well, this new python typing standard is too new, let's wait if it catches on at all and which tools will be used.". In 2024 the situation is a _little_ different imho. Type Checking is about making it possible to catch programming errors at compile time/coding time, instead of runtime. Of course, it's a trade-off, nothing is free of opportunity cost. I just had a review where a Typed Class caught an error, because an element was missing from a dict initialization. The original code was of course untyped. By encoding the needed elements in the class, the linter yells at you in your editor that you are missing a required element. This was in openstack. We all make mistakes, that's not the point. But I want to use features, that catch my mistakes, because no reviewer can catch all failures. This also helps reduce CI cycles, and preserve resources, by catching errors in my source editor, instead of during some CI test (if I'm lucky). There are academic papers out there - from 2013 - that show static typing improves maintainability[4]. I'm a little bit baffled that static typing seems to be controversial in the year 2024. I wish there was more academic rigor, when it comes to opinions about facts in information technology. I'm honestly tired of these discussions. [1]: https://mail.python.org/pipermail/python-dev/2015-May/140104.html [2]: https://mypy-lang.org/about.html [3]: https://github.com/python/mypy/commit/14702418afc3bde9511ee50e5b76db7ad565f8... [4]: https://www.researchgate.net/publication/259634489_An_empirical_study_on_the... (paywalled, abstract available) kind regards -- Sven Kieske Senior Cloud Engineer Mail: kieske@osism.tech Web: https://osism.tech OSISM GmbH Teckstraße 62 / 70190 Stuttgart / Deutschland Geschäftsführer: Christian Berendt Unternehmenssitz: Stuttgart Amtsgericht: Stuttgart, HRB 756139